diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/_meta.json b/sdk/devtestlabs/azure-mgmt-devtestlabs/_meta.json new file mode 100644 index 000000000000..5196aee8c88d --- /dev/null +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "e7da1b7cefd3d42a4d97145ffe9e0336da08cea0", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/devtestlabs/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/devtestlabs/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/__init__.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/__init__.py index 072325c48b8d..c9e4ae34ca5b 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/__init__.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['DevTestLabsClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._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/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_configuration.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_configuration.py index e219dd5413dc..09839e6f6164 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_configuration.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class DevTestLabsClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DevTestLabsClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(DevTestLabsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_dev_test_labs_client.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_dev_test_labs_client.py index 292b59cccf08..6b1f55ce7a43 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_dev_test_labs_client.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_dev_test_labs_client.py @@ -6,47 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import DevTestLabsClientConfiguration +from .operations import ArmTemplatesOperations, ArtifactSourcesOperations, ArtifactsOperations, CostsOperations, CustomImagesOperations, DisksOperations, EnvironmentsOperations, FormulasOperations, GalleryImagesOperations, GlobalSchedulesOperations, LabsOperations, NotificationChannelsOperations, Operations, PoliciesOperations, PolicySetsOperations, ProviderOperationsOperations, SchedulesOperations, SecretsOperations, ServiceFabricSchedulesOperations, ServiceFabricsOperations, ServiceRunnersOperations, UsersOperations, VirtualMachineSchedulesOperations, VirtualMachinesOperations, VirtualNetworksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import DevTestLabsClientConfiguration -from .operations import ProviderOperationsOperations -from .operations import LabsOperations -from .operations import Operations -from .operations import GlobalSchedulesOperations -from .operations import ArtifactSourcesOperations -from .operations import ArmTemplatesOperations -from .operations import ArtifactsOperations -from .operations import CostsOperations -from .operations import CustomImagesOperations -from .operations import FormulasOperations -from .operations import GalleryImagesOperations -from .operations import NotificationChannelsOperations -from .operations import PolicySetsOperations -from .operations import PoliciesOperations -from .operations import SchedulesOperations -from .operations import ServiceRunnersOperations -from .operations import UsersOperations -from .operations import DisksOperations -from .operations import EnvironmentsOperations -from .operations import SecretsOperations -from .operations import ServiceFabricsOperations -from .operations import ServiceFabricSchedulesOperations -from .operations import VirtualMachinesOperations -from .operations import VirtualMachineSchedulesOperations -from .operations import VirtualNetworksOperations -from . import models - - -class DevTestLabsClient(object): +class DevTestLabsClient: """The DevTest Labs Client. :ivar provider_operations: ProviderOperationsOperations operations @@ -72,7 +47,8 @@ class DevTestLabsClient(object): :ivar gallery_images: GalleryImagesOperations operations :vartype gallery_images: azure.mgmt.devtestlabs.operations.GalleryImagesOperations :ivar notification_channels: NotificationChannelsOperations operations - :vartype notification_channels: azure.mgmt.devtestlabs.operations.NotificationChannelsOperations + :vartype notification_channels: + azure.mgmt.devtestlabs.operations.NotificationChannelsOperations :ivar policy_sets: PolicySetsOperations operations :vartype policy_sets: azure.mgmt.devtestlabs.operations.PolicySetsOperations :ivar policies: PoliciesOperations operations @@ -92,89 +68,91 @@ class DevTestLabsClient(object): :ivar service_fabrics: ServiceFabricsOperations operations :vartype service_fabrics: azure.mgmt.devtestlabs.operations.ServiceFabricsOperations :ivar service_fabric_schedules: ServiceFabricSchedulesOperations operations - :vartype service_fabric_schedules: azure.mgmt.devtestlabs.operations.ServiceFabricSchedulesOperations + :vartype service_fabric_schedules: + azure.mgmt.devtestlabs.operations.ServiceFabricSchedulesOperations :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.devtestlabs.operations.VirtualMachinesOperations :ivar virtual_machine_schedules: VirtualMachineSchedulesOperations operations - :vartype virtual_machine_schedules: azure.mgmt.devtestlabs.operations.VirtualMachineSchedulesOperations + :vartype virtual_machine_schedules: + azure.mgmt.devtestlabs.operations.VirtualMachineSchedulesOperations :ivar virtual_networks: VirtualNetworksOperations operations :vartype virtual_networks: azure.mgmt.devtestlabs.operations.VirtualNetworksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription ID. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DevTestLabsClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DevTestLabsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.provider_operations = ProviderOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.labs = LabsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.global_schedules = GlobalSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifact_sources = ArtifactSourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.arm_templates = ArmTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifacts = ArtifactsOperations(self._client, self._config, self._serialize, self._deserialize) + self.costs = CostsOperations(self._client, self._config, self._serialize, self._deserialize) + self.custom_images = CustomImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.formulas = FormulasOperations(self._client, self._config, self._serialize, self._deserialize) + self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.notification_channels = NotificationChannelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_sets = PolicySetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedules = SchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_runners = ServiceRunnersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) + self.environments = EnvironmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_fabrics = ServiceFabricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_fabric_schedules = ServiceFabricSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_schedules = VirtualMachineSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_networks = VirtualNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ - self.provider_operations = ProviderOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.labs = LabsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.global_schedules = GlobalSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.artifact_sources = ArtifactSourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.arm_templates = ArmTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.artifacts = ArtifactsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.costs = CostsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.custom_images = CustomImagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.formulas = FormulasOperations( - self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.notification_channels = NotificationChannelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_sets = PolicySetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policies = PoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.schedules = SchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_runners = ServiceRunnersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.environments = EnvironmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.secrets = SecretsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_fabrics = ServiceFabricsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_fabric_schedules = ServiceFabricSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_schedules = VirtualMachineSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_networks = VirtualNetworksOperations( - self._client, self._config, self._serialize, self._deserialize) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_metadata.json b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_metadata.json new file mode 100644 index 000000000000..f2c4ad320051 --- /dev/null +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_metadata.json @@ -0,0 +1,126 @@ +{ + "chosen_version": "2018-09-15", + "total_api_version_list": ["2018-09-15"], + "client": { + "name": "DevTestLabsClient", + "filename": "_dev_test_labs_client", + "description": "The DevTest Labs Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DevTestLabsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DevTestLabsClientConfiguration\"]}}, \"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 subscription ID.", + "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 subscription ID.", + "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": { + "provider_operations": "ProviderOperationsOperations", + "labs": "LabsOperations", + "operations": "Operations", + "global_schedules": "GlobalSchedulesOperations", + "artifact_sources": "ArtifactSourcesOperations", + "arm_templates": "ArmTemplatesOperations", + "artifacts": "ArtifactsOperations", + "costs": "CostsOperations", + "custom_images": "CustomImagesOperations", + "formulas": "FormulasOperations", + "gallery_images": "GalleryImagesOperations", + "notification_channels": "NotificationChannelsOperations", + "policy_sets": "PolicySetsOperations", + "policies": "PoliciesOperations", + "schedules": "SchedulesOperations", + "service_runners": "ServiceRunnersOperations", + "users": "UsersOperations", + "disks": "DisksOperations", + "environments": "EnvironmentsOperations", + "secrets": "SecretsOperations", + "service_fabrics": "ServiceFabricsOperations", + "service_fabric_schedules": "ServiceFabricSchedulesOperations", + "virtual_machines": "VirtualMachinesOperations", + "virtual_machine_schedules": "VirtualMachineSchedulesOperations", + "virtual_networks": "VirtualNetworksOperations" + } +} \ No newline at end of file diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_patch.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_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/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_vendor.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_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/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_version.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_version.py index b77ac9246082..c47f66669f1b 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_version.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "9.0.0" +VERSION = "1.0.0" diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/__init__.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/__init__.py index 170e58187e15..3f3585f01280 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/__init__.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/__init__.py @@ -8,3 +8,8 @@ from ._dev_test_labs_client import DevTestLabsClient __all__ = ['DevTestLabsClient'] + +# `._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/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_configuration.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_configuration.py index 631f908540c5..dadd5c7b7f3c 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_configuration.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(DevTestLabsClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(DevTestLabsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_dev_test_labs_client.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_dev_test_labs_client.py index e54b913aa64a..515c07ab7ff5 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_dev_test_labs_client.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_dev_test_labs_client.py @@ -6,49 +6,27 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import DevTestLabsClientConfiguration +from .operations import ArmTemplatesOperations, ArtifactSourcesOperations, ArtifactsOperations, CostsOperations, CustomImagesOperations, DisksOperations, EnvironmentsOperations, FormulasOperations, GalleryImagesOperations, GlobalSchedulesOperations, LabsOperations, NotificationChannelsOperations, Operations, PoliciesOperations, PolicySetsOperations, ProviderOperationsOperations, SchedulesOperations, SecretsOperations, ServiceFabricSchedulesOperations, ServiceFabricsOperations, ServiceRunnersOperations, UsersOperations, VirtualMachineSchedulesOperations, VirtualMachinesOperations, VirtualNetworksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DevTestLabsClientConfiguration -from .operations import ProviderOperationsOperations -from .operations import LabsOperations -from .operations import Operations -from .operations import GlobalSchedulesOperations -from .operations import ArtifactSourcesOperations -from .operations import ArmTemplatesOperations -from .operations import ArtifactsOperations -from .operations import CostsOperations -from .operations import CustomImagesOperations -from .operations import FormulasOperations -from .operations import GalleryImagesOperations -from .operations import NotificationChannelsOperations -from .operations import PolicySetsOperations -from .operations import PoliciesOperations -from .operations import SchedulesOperations -from .operations import ServiceRunnersOperations -from .operations import UsersOperations -from .operations import DisksOperations -from .operations import EnvironmentsOperations -from .operations import SecretsOperations -from .operations import ServiceFabricsOperations -from .operations import ServiceFabricSchedulesOperations -from .operations import VirtualMachinesOperations -from .operations import VirtualMachineSchedulesOperations -from .operations import VirtualNetworksOperations -from .. import models - - -class DevTestLabsClient(object): +class DevTestLabsClient: """The DevTest Labs Client. :ivar provider_operations: ProviderOperationsOperations operations - :vartype provider_operations: azure.mgmt.devtestlabs.aio.operations.ProviderOperationsOperations + :vartype provider_operations: + azure.mgmt.devtestlabs.aio.operations.ProviderOperationsOperations :ivar labs: LabsOperations operations :vartype labs: azure.mgmt.devtestlabs.aio.operations.LabsOperations :ivar operations: Operations operations @@ -70,7 +48,8 @@ class DevTestLabsClient(object): :ivar gallery_images: GalleryImagesOperations operations :vartype gallery_images: azure.mgmt.devtestlabs.aio.operations.GalleryImagesOperations :ivar notification_channels: NotificationChannelsOperations operations - :vartype notification_channels: azure.mgmt.devtestlabs.aio.operations.NotificationChannelsOperations + :vartype notification_channels: + azure.mgmt.devtestlabs.aio.operations.NotificationChannelsOperations :ivar policy_sets: PolicySetsOperations operations :vartype policy_sets: azure.mgmt.devtestlabs.aio.operations.PolicySetsOperations :ivar policies: PoliciesOperations operations @@ -90,88 +69,91 @@ class DevTestLabsClient(object): :ivar service_fabrics: ServiceFabricsOperations operations :vartype service_fabrics: azure.mgmt.devtestlabs.aio.operations.ServiceFabricsOperations :ivar service_fabric_schedules: ServiceFabricSchedulesOperations operations - :vartype service_fabric_schedules: azure.mgmt.devtestlabs.aio.operations.ServiceFabricSchedulesOperations + :vartype service_fabric_schedules: + azure.mgmt.devtestlabs.aio.operations.ServiceFabricSchedulesOperations :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.devtestlabs.aio.operations.VirtualMachinesOperations :ivar virtual_machine_schedules: VirtualMachineSchedulesOperations operations - :vartype virtual_machine_schedules: azure.mgmt.devtestlabs.aio.operations.VirtualMachineSchedulesOperations + :vartype virtual_machine_schedules: + azure.mgmt.devtestlabs.aio.operations.VirtualMachineSchedulesOperations :ivar virtual_networks: VirtualNetworksOperations operations :vartype virtual_networks: azure.mgmt.devtestlabs.aio.operations.VirtualNetworksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription ID. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DevTestLabsClientConfiguration(credential, subscription_id, **kwargs) + self._config = DevTestLabsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.provider_operations = ProviderOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.labs = LabsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.global_schedules = GlobalSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifact_sources = ArtifactSourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.arm_templates = ArmTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifacts = ArtifactsOperations(self._client, self._config, self._serialize, self._deserialize) + self.costs = CostsOperations(self._client, self._config, self._serialize, self._deserialize) + self.custom_images = CustomImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.formulas = FormulasOperations(self._client, self._config, self._serialize, self._deserialize) + self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.notification_channels = NotificationChannelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_sets = PolicySetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedules = SchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_runners = ServiceRunnersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) + self.environments = EnvironmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_fabrics = ServiceFabricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_fabric_schedules = ServiceFabricSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_schedules = VirtualMachineSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_networks = VirtualNetworksOperations(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 + """ - self.provider_operations = ProviderOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.labs = LabsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.global_schedules = GlobalSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.artifact_sources = ArtifactSourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.arm_templates = ArmTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.artifacts = ArtifactsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.costs = CostsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.custom_images = CustomImagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.formulas = FormulasOperations( - self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.notification_channels = NotificationChannelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_sets = PolicySetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policies = PoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.schedules = SchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_runners = ServiceRunnersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.environments = EnvironmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.secrets = SecretsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_fabrics = ServiceFabricsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_fabric_schedules = ServiceFabricSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_schedules = VirtualMachineSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_networks = VirtualNetworksOperations( - self._client, self._config, self._serialize, self._deserialize) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_patch.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/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/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_arm_templates_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_arm_templates_operations.py index 55850951470a..f520cc421bbd 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_arm_templates_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_arm_templates_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.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._arm_templates_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -50,7 +56,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ArmTemplateList"]: """List azure resource manager templates in a given artifact source. @@ -79,45 +85,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ArmTemplateList', pipeline_response) + deserialized = self._deserialize("ArmTemplateList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -135,11 +139,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/armtemplates'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -147,7 +153,7 @@ async def get( artifact_source_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.ArmTemplate": """Get azure resource manager template. @@ -171,31 +177,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,4 +204,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/armtemplates/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_artifact_sources_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_artifact_sources_operations.py index aad52c573238..7896601a528d 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_artifact_sources_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_artifact_sources_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.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._artifact_sources_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -49,7 +55,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ArtifactSourceList"]: """List artifact sources in a given lab. @@ -68,7 +74,8 @@ def list( :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ArtifactSourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.ArtifactSourceList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.ArtifactSourceList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactSourceList"] @@ -76,44 +83,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ArtifactSourceList', pipeline_response) + deserialized = self._deserialize("ArtifactSourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,18 +135,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.ArtifactSource": """Get artifact source. @@ -164,30 +170,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -201,15 +196,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, lab_name: str, name: str, artifact_source: "_models.ArtifactSource", - **kwargs + **kwargs: Any ) -> "_models.ArtifactSource": """Create or replace an existing artifact source. @@ -231,33 +229,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(artifact_source, 'ArtifactSource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(artifact_source, 'ArtifactSource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -275,14 +263,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete artifact source. @@ -302,28 +293,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -336,13 +317,15 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, name: str, - artifact_source: "_models.ArtifactSourceFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.ArtifactSource": """Allows modifying tags of artifact sources. All other properties will be ignored. @@ -352,8 +335,8 @@ async def update( :type lab_name: str :param name: The name of the artifact source. :type name: str - :param artifact_source: Properties of an artifact source. - :type artifact_source: ~azure.mgmt.devtestlabs.models.ArtifactSourceFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: ArtifactSource, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.ArtifactSource @@ -364,33 +347,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _artifact_source = _models.ArtifactSourceFragment(tags=tags) + _json = self._serialize.body(_artifact_source, 'ArtifactSourceFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(artifact_source, 'ArtifactSourceFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -404,4 +378,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_artifacts_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_artifacts_operations.py index 68bed6059bde..48f674557ccd 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_artifacts_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_artifacts_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.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._artifacts_operations import build_generate_arm_template_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -50,7 +56,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ArtifactList"]: """List artifacts in a given artifact source. @@ -79,45 +85,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ArtifactList', pipeline_response) + deserialized = self._deserialize("ArtifactList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -135,11 +139,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -147,7 +153,7 @@ async def get( artifact_source_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Artifact": """Get artifact. @@ -171,31 +177,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,8 +204,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}'} # type: ignore + + @distributed_trace_async async def generate_arm_template( self, resource_group_name: str, @@ -218,7 +216,7 @@ async def generate_arm_template( artifact_source_name: str, name: str, generate_arm_template_request: "_models.GenerateArmTemplateRequest", - **kwargs + **kwargs: Any ) -> "_models.ArmTemplateInfo": """Generates an ARM template for the given artifact, uploads the required files to a storage account, and validates the generated artifact. @@ -244,34 +242,24 @@ async def generate_arm_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.generate_arm_template.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(generate_arm_template_request, 'GenerateArmTemplateRequest') + + request = build_generate_arm_template_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.generate_arm_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(generate_arm_template_request, 'GenerateArmTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,4 +273,6 @@ async def generate_arm_template( return cls(pipeline_response, deserialized, {}) return deserialized + generate_arm_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}/generateArmTemplate'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_costs_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_costs_operations.py index 86a66ff8307c..d1bafa00e47c 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_costs_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_costs_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._costs_operations import build_create_or_update_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +44,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.LabCost": """Get cost. @@ -68,30 +73,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,15 +99,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, lab_name: str, name: str, lab_cost: "_models.LabCost", - **kwargs + **kwargs: Any ) -> "_models.LabCost": """Create or replace an existing cost. @@ -135,33 +132,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(lab_cost, 'LabCost') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_cost, 'LabCost') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,4 +166,6 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_custom_images_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_custom_images_operations.py index 67cad5bcf5b0..faa4c65b704b 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_custom_images_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_custom_images_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._custom_images_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -51,7 +57,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.CustomImageList"]: """List custom images in a given lab. @@ -78,44 +84,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('CustomImageList', pipeline_response) + deserialized = self._deserialize("CustomImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,18 +136,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.CustomImage": """Get custom image. @@ -166,30 +171,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -203,48 +197,40 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, lab_name: str, name: str, custom_image: "_models.CustomImage", - **kwargs + **kwargs: Any ) -> "_models.CustomImage": cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(custom_image, 'CustomImage') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(custom_image, 'CustomImage') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -262,15 +248,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, lab_name: str, name: str, custom_image: "_models.CustomImage", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.CustomImage"]: """Create or replace an existing custom image. This operation can take a while to complete. @@ -284,15 +273,19 @@ async def begin_create_or_update( :type custom_image: ~azure.mgmt.devtestlabs.models.CustomImage :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either CustomImage or the result of cls(response) + :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 CustomImage or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.CustomImage] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomImage"] lro_delay = kwargs.pop( 'polling_interval', @@ -305,28 +298,21 @@ async def begin_create_or_update( lab_name=lab_name, name=name, custom_image=custom_image, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CustomImage', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -338,6 +324,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore async def _delete_initial( @@ -345,35 +332,25 @@ async def _delete_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -386,12 +363,14 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete custom image. This operation can take a while to complete. @@ -403,15 +382,17 @@ async def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -426,22 +407,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -453,15 +426,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, name: str, - custom_image: "_models.CustomImageFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.CustomImage": """Allows modifying tags of custom images. All other properties will be ignored. @@ -471,8 +446,8 @@ async def update( :type lab_name: str :param name: The name of the custom image. :type name: str - :param custom_image: A custom image. - :type custom_image: ~azure.mgmt.devtestlabs.models.CustomImageFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomImage, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.CustomImage @@ -483,33 +458,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _custom_image = _models.CustomImageFragment(tags=tags) + _json = self._serialize.body(_custom_image, 'CustomImageFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(custom_image, 'CustomImageFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -523,4 +489,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_disks_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_disks_operations.py index 02cb285e430a..b9c47733c7de 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_disks_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_disks_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._disks_operations import build_attach_request_initial, build_create_or_update_request_initial, build_delete_request_initial, build_detach_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -52,7 +58,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DiskList"]: """List disks in a given user profile. @@ -81,45 +87,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('DiskList', pipeline_response) + deserialized = self._deserialize("DiskList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,11 +141,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,7 +155,7 @@ async def get( user_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Disk": """Get disk. @@ -173,31 +179,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +206,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -220,41 +217,31 @@ async def _create_or_update_initial( user_name: str, name: str, disk: "_models.Disk", - **kwargs + **kwargs: Any ) -> "_models.Disk": cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(disk, 'Disk') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(disk, 'Disk') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -272,8 +259,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -281,7 +271,7 @@ async def begin_create_or_update( user_name: str, name: str, disk: "_models.Disk", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.Disk"]: """Create or replace an existing disk. This operation can take a while to complete. @@ -297,15 +287,18 @@ async def begin_create_or_update( :type disk: ~azure.mgmt.devtestlabs.models.Disk :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', @@ -319,29 +312,21 @@ async def begin_create_or_update( user_name=user_name, name=name, disk=disk, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Disk', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -353,6 +338,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore async def _delete_initial( @@ -361,36 +347,26 @@ async def _delete_initial( lab_name: str, user_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -403,13 +379,15 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete disk. This operation can take a while to complete. @@ -423,15 +401,17 @@ async def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -447,23 +427,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -475,16 +446,18 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - disk: "_models.DiskFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.Disk": """Allows modifying tags of disks. All other properties will be ignored. @@ -496,8 +469,8 @@ async def update( :type user_name: str :param name: The name of the disk. :type name: str - :param disk: A Disk. - :type disk: ~azure.mgmt.devtestlabs.models.DiskFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Disk, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Disk @@ -508,34 +481,25 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _disk = _models.DiskFragment(tags=tags) + _json = self._serialize.body(_disk, 'DiskFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(disk, 'DiskFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -549,8 +513,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + async def _attach_initial( self, resource_group_name: str, @@ -558,7 +524,7 @@ async def _attach_initial( user_name: str, name: str, leased_by_lab_vm_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -566,35 +532,24 @@ async def _attach_initial( } error_map.update(kwargs.pop('error_map', {})) - _attach_disk_properties = _models.AttachDiskProperties(leased_by_lab_vm_id=leased_by_lab_vm_id) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._attach_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _attach_disk_properties = _models.AttachDiskProperties(leased_by_lab_vm_id=leased_by_lab_vm_id) + _json = self._serialize.body(_attach_disk_properties, 'AttachDiskProperties') + + request = build_attach_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._attach_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_attach_disk_properties, 'AttachDiskProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -607,6 +562,8 @@ async def _attach_initial( _attach_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/attach'} # type: ignore + + @distributed_trace_async async def begin_attach( self, resource_group_name: str, @@ -614,7 +571,7 @@ async def begin_attach( user_name: str, name: str, leased_by_lab_vm_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Attach and create the lease of the disk to the virtual machine. This operation can take a while to complete. @@ -632,15 +589,18 @@ async def begin_attach( :type leased_by_lab_vm_id: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -654,26 +614,18 @@ async def begin_attach( user_name=user_name, name=name, leased_by_lab_vm_id=leased_by_lab_vm_id, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -685,6 +637,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_attach.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/attach'} # type: ignore async def _detach_initial( @@ -694,7 +647,7 @@ async def _detach_initial( user_name: str, name: str, leased_by_lab_vm_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -702,35 +655,24 @@ async def _detach_initial( } error_map.update(kwargs.pop('error_map', {})) - _detach_disk_properties = _models.DetachDiskProperties(leased_by_lab_vm_id=leased_by_lab_vm_id) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._detach_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _detach_disk_properties = _models.DetachDiskProperties(leased_by_lab_vm_id=leased_by_lab_vm_id) + _json = self._serialize.body(_detach_disk_properties, 'DetachDiskProperties') + + request = build_detach_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._detach_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_detach_disk_properties, 'DetachDiskProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -743,6 +685,8 @@ async def _detach_initial( _detach_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/detach'} # type: ignore + + @distributed_trace_async async def begin_detach( self, resource_group_name: str, @@ -750,7 +694,7 @@ async def begin_detach( user_name: str, name: str, leased_by_lab_vm_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Detach and break the lease of the disk attached to the virtual machine. This operation can take a while to complete. @@ -767,15 +711,18 @@ async def begin_detach( :type leased_by_lab_vm_id: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -789,26 +736,18 @@ async def begin_detach( user_name=user_name, name=name, leased_by_lab_vm_id=leased_by_lab_vm_id, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -820,4 +759,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_detach.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/detach'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_environments_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_environments_operations.py index 06d7746ab9ef..7450c38dd9a2 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_environments_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_environments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._environments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -52,7 +58,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DtlEnvironmentList"]: """List environments in a given user profile. @@ -73,7 +79,8 @@ def list( :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DtlEnvironmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.DtlEnvironmentList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.DtlEnvironmentList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DtlEnvironmentList"] @@ -81,45 +88,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('DtlEnvironmentList', pipeline_response) + deserialized = self._deserialize("DtlEnvironmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,11 +142,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,7 +156,7 @@ async def get( user_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.DtlEnvironment": """Get environment. @@ -173,31 +180,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +207,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -220,41 +218,31 @@ async def _create_or_update_initial( user_name: str, name: str, dtl_environment: "_models.DtlEnvironment", - **kwargs + **kwargs: Any ) -> "_models.DtlEnvironment": cls = kwargs.pop('cls', None) # type: ClsType["_models.DtlEnvironment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(dtl_environment, 'DtlEnvironment') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(dtl_environment, 'DtlEnvironment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -272,8 +260,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -281,7 +272,7 @@ async def begin_create_or_update( user_name: str, name: str, dtl_environment: "_models.DtlEnvironment", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.DtlEnvironment"]: """Create or replace an existing environment. This operation can take a while to complete. @@ -297,15 +288,19 @@ async def begin_create_or_update( :type dtl_environment: ~azure.mgmt.devtestlabs.models.DtlEnvironment :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DtlEnvironment or the result of cls(response) + :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 DtlEnvironment or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.DtlEnvironment] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DtlEnvironment"] lro_delay = kwargs.pop( 'polling_interval', @@ -319,29 +314,21 @@ async def begin_create_or_update( user_name=user_name, name=name, dtl_environment=dtl_environment, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DtlEnvironment', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -353,6 +340,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore async def _delete_initial( @@ -361,36 +349,26 @@ async def _delete_initial( lab_name: str, user_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -403,13 +381,15 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete environment. This operation can take a while to complete. @@ -423,15 +403,17 @@ async def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -447,23 +429,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -475,16 +448,18 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - dtl_environment: "_models.DtlEnvironmentFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.DtlEnvironment": """Allows modifying tags of environments. All other properties will be ignored. @@ -496,8 +471,8 @@ async def update( :type user_name: str :param name: The name of the environment. :type name: str - :param dtl_environment: An environment, which is essentially an ARM template deployment. - :type dtl_environment: ~azure.mgmt.devtestlabs.models.DtlEnvironmentFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: DtlEnvironment, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.DtlEnvironment @@ -508,34 +483,25 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _dtl_environment = _models.DtlEnvironmentFragment(tags=tags) + _json = self._serialize.body(_dtl_environment, 'DtlEnvironmentFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(dtl_environment, 'DtlEnvironmentFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -549,4 +515,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_formulas_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_formulas_operations.py index 2753d74534f9..c33b675fe325 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_formulas_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_formulas_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._formulas_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -51,7 +57,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.FormulaList"]: """List formulas in a given lab. @@ -78,44 +84,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('FormulaList', pipeline_response) + deserialized = self._deserialize("FormulaList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,18 +136,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Formula": """Get formula. @@ -166,30 +171,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -203,48 +197,40 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, lab_name: str, name: str, formula: "_models.Formula", - **kwargs + **kwargs: Any ) -> "_models.Formula": cls = kwargs.pop('cls', None) # type: ClsType["_models.Formula"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(formula, 'Formula') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(formula, 'Formula') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -262,15 +248,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, lab_name: str, name: str, formula: "_models.Formula", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.Formula"]: """Create or replace an existing formula. This operation can take a while to complete. @@ -284,15 +273,19 @@ async def begin_create_or_update( :type formula: ~azure.mgmt.devtestlabs.models.Formula :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Formula or the result of cls(response) + :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 Formula or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.Formula] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Formula"] lro_delay = kwargs.pop( 'polling_interval', @@ -305,28 +298,21 @@ async def begin_create_or_update( lab_name=lab_name, name=name, formula=formula, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Formula', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -338,14 +324,16 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + @distributed_trace_async async def delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete formula. @@ -365,28 +353,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -399,13 +377,15 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, name: str, - formula: "_models.FormulaFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.Formula": """Allows modifying tags of formulas. All other properties will be ignored. @@ -415,8 +395,8 @@ async def update( :type lab_name: str :param name: The name of the formula. :type name: str - :param formula: A formula for creating a VM, specifying an image base and other parameters. - :type formula: ~azure.mgmt.devtestlabs.models.FormulaFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Formula, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Formula @@ -427,33 +407,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _formula = _models.FormulaFragment(tags=tags) + _json = self._serialize.body(_formula, 'FormulaFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(formula, 'FormulaFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,4 +438,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_gallery_images_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_gallery_images_operations.py index 3b30158b713e..eb971942b22c 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_gallery_images_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_gallery_images_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.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._gallery_images_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -49,7 +55,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.GalleryImageList"]: """List gallery images in a given lab. @@ -68,7 +74,8 @@ def list( :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GalleryImageList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.GalleryImageList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] @@ -76,44 +83,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('GalleryImageList', pipeline_response) + deserialized = self._deserialize("GalleryImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,6 +135,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_global_schedules_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_global_schedules_operations.py index a0bb8f037e5d..a66fefc732c4 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_global_schedules_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_global_schedules_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._global_schedules_operations import build_create_or_update_request, build_delete_request, build_execute_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_retarget_request_initial, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,13 +48,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, expand: Optional[str] = None, filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ScheduleList"]: """List schedules in a subscription. @@ -72,42 +78,37 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,11 +126,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/schedules'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -137,7 +140,7 @@ def list_by_resource_group( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ScheduleList"]: """List schedules in a resource group. @@ -162,43 +165,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -216,17 +215,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Get schedule. @@ -246,29 +247,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -282,14 +272,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, name: str, schedule: "_models.Schedule", - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Create or replace an existing schedule. @@ -309,32 +302,22 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(schedule, 'Schedule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'Schedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -352,13 +335,16 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete schedule. @@ -376,27 +362,17 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -409,12 +385,14 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, name: str, - schedule: "_models.ScheduleFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.Schedule": """Allows modifying tags of schedules. All other properties will be ignored. @@ -422,8 +400,8 @@ async def update( :type resource_group_name: str :param name: The name of the schedule. :type name: str - :param schedule: A schedule. - :type schedule: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Schedule @@ -434,32 +412,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _schedule = _models.ScheduleFragment(tags=tags) + _json = self._serialize.body(_schedule, 'ScheduleFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'ScheduleFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -473,40 +442,32 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}'} # type: ignore + async def _execute_initial( self, resource_group_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._execute_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_execute_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self._execute_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -519,11 +480,13 @@ async def _execute_initial( _execute_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/execute'} # type: ignore + + @distributed_trace_async async def begin_execute( self, resource_group_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Execute a schedule. This operation can take a while to complete. @@ -533,15 +496,17 @@ async def begin_execute( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -555,21 +520,14 @@ async def begin_execute( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -581,6 +539,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_execute.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/execute'} # type: ignore async def _retarget_initial( @@ -589,7 +548,7 @@ async def _retarget_initial( name: str, current_resource_id: Optional[str] = None, target_resource_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -597,33 +556,22 @@ async def _retarget_initial( } error_map.update(kwargs.pop('error_map', {})) - _retarget_schedule_properties = _models.RetargetScheduleProperties(current_resource_id=current_resource_id, target_resource_id=target_resource_id) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._retarget_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _retarget_schedule_properties = _models.RetargetScheduleProperties(current_resource_id=current_resource_id, target_resource_id=target_resource_id) + _json = self._serialize.body(_retarget_schedule_properties, 'RetargetScheduleProperties') + + request = build_retarget_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._retarget_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_retarget_schedule_properties, 'RetargetScheduleProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -636,13 +584,15 @@ async def _retarget_initial( _retarget_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/retarget'} # type: ignore + + @distributed_trace_async async def begin_retarget( self, resource_group_name: str, name: str, current_resource_id: Optional[str] = None, target_resource_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates a schedule's target resource Id. This operation can take a while to complete. @@ -658,15 +608,18 @@ async def begin_retarget( :type target_resource_id: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -679,24 +632,18 @@ async def begin_retarget( name=name, current_resource_id=current_resource_id, target_resource_id=target_resource_id, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -708,4 +655,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_retarget.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/retarget'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_labs_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_labs_operations.py index a705d8403efc..f16164d7f5fa 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_labs_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_labs_operations.py @@ -6,19 +6,24 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._labs_operations import build_claim_any_vm_request_initial, build_create_environment_request_initial, build_create_or_update_request_initial, build_delete_request_initial, build_export_resource_usage_request_initial, build_generate_upload_uri_request, build_get_request, build_import_virtual_machine_request_initial, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_vhds_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,13 +49,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, expand: Optional[str] = None, filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.LabList"]: """List labs in a subscription. @@ -73,42 +79,37 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('LabList', pipeline_response) + deserialized = self._deserialize("LabList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,11 +127,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/labs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -138,7 +141,7 @@ def list_by_resource_group( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.LabList"]: """List labs in a resource group. @@ -163,43 +166,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('LabList', pipeline_response) + deserialized = self._deserialize("LabList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -217,17 +216,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Lab": """Get lab. @@ -247,29 +248,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -283,46 +273,38 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, name: str, lab: "_models.Lab", - **kwargs + **kwargs: Any ) -> "_models.Lab": cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(lab, 'Lab') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab, 'Lab') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -340,14 +322,17 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, name: str, lab: "_models.Lab", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.Lab"]: """Create or replace an existing lab. This operation can take a while to complete. @@ -359,15 +344,18 @@ async def begin_create_or_update( :type lab: ~azure.mgmt.devtestlabs.models.Lab :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Lab or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.Lab] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] lro_delay = kwargs.pop( 'polling_interval', @@ -379,27 +367,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, name=name, lab=lab, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Lab', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -411,40 +393,31 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore async def _delete_initial( self, resource_group_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -457,11 +430,13 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete lab. This operation can take a while to complete. @@ -471,15 +446,17 @@ async def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -493,21 +470,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -519,14 +489,16 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, name: str, - lab: "_models.LabFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.Lab": """Allows modifying tags of labs. All other properties will be ignored. @@ -534,8 +506,8 @@ async def update( :type resource_group_name: str :param name: The name of the lab. :type name: str - :param lab: A lab. - :type lab: ~azure.mgmt.devtestlabs.models.LabFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Lab, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Lab @@ -546,32 +518,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _lab = _models.LabFragment(tags=tags) + _json = self._serialize.body(_lab, 'LabFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab, 'LabFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -585,40 +548,32 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + async def _claim_any_vm_initial( self, resource_group_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._claim_any_vm_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_claim_any_vm_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self._claim_any_vm_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -631,11 +586,13 @@ async def _claim_any_vm_initial( _claim_any_vm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/claimAnyVm'} # type: ignore + + @distributed_trace_async async def begin_claim_any_vm( self, resource_group_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Claim a random claimable virtual machine in the lab. This operation can take a while to complete. @@ -646,15 +603,17 @@ async def begin_claim_any_vm( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -668,21 +627,14 @@ async def begin_claim_any_vm( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -694,6 +646,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_claim_any_vm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/claimAnyVm'} # type: ignore async def _create_environment_initial( @@ -701,39 +654,29 @@ async def _create_environment_initial( resource_group_name: str, name: str, lab_virtual_machine_creation_parameter: "_models.LabVirtualMachineCreationParameter", - **kwargs + **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 = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_environment_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(lab_virtual_machine_creation_parameter, 'LabVirtualMachineCreationParameter') + + request = build_create_environment_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_environment_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_virtual_machine_creation_parameter, 'LabVirtualMachineCreationParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -746,12 +689,14 @@ async def _create_environment_initial( _create_environment_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment'} # type: ignore + + @distributed_trace_async async def begin_create_environment( self, resource_group_name: str, name: str, lab_virtual_machine_creation_parameter: "_models.LabVirtualMachineCreationParameter", - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Create virtual machines in a lab. This operation can take a while to complete. @@ -760,18 +705,22 @@ async def begin_create_environment( :param name: The name of the lab. :type name: str :param lab_virtual_machine_creation_parameter: Properties for creating a virtual machine. - :type lab_virtual_machine_creation_parameter: ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameter + :type lab_virtual_machine_creation_parameter: + ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameter :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -783,24 +732,18 @@ async def begin_create_environment( resource_group_name=resource_group_name, name=name, lab_virtual_machine_creation_parameter=lab_virtual_machine_creation_parameter, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -812,6 +755,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_environment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment'} # type: ignore async def _export_resource_usage_initial( @@ -820,7 +764,7 @@ async def _export_resource_usage_initial( name: str, blob_storage_absolute_sas_uri: Optional[str] = None, usage_start_date: Optional[datetime.datetime] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -828,33 +772,22 @@ async def _export_resource_usage_initial( } error_map.update(kwargs.pop('error_map', {})) - _export_resource_usage_parameters = _models.ExportResourceUsageParameters(blob_storage_absolute_sas_uri=blob_storage_absolute_sas_uri, usage_start_date=usage_start_date) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_resource_usage_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _export_resource_usage_parameters = _models.ExportResourceUsageParameters(blob_storage_absolute_sas_uri=blob_storage_absolute_sas_uri, usage_start_date=usage_start_date) + _json = self._serialize.body(_export_resource_usage_parameters, 'ExportResourceUsageParameters') + + request = build_export_resource_usage_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._export_resource_usage_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_export_resource_usage_parameters, 'ExportResourceUsageParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -867,13 +800,15 @@ async def _export_resource_usage_initial( _export_resource_usage_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/exportResourceUsage'} # type: ignore + + @distributed_trace_async async def begin_export_resource_usage( self, resource_group_name: str, name: str, blob_storage_absolute_sas_uri: Optional[str] = None, usage_start_date: Optional[datetime.datetime] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Exports the lab resource usage into a storage account This operation can take a while to complete. @@ -890,15 +825,18 @@ async def begin_export_resource_usage( :type usage_start_date: ~datetime.datetime :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -911,24 +849,18 @@ async def begin_export_resource_usage( name=name, blob_storage_absolute_sas_uri=blob_storage_absolute_sas_uri, usage_start_date=usage_start_date, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -940,14 +872,16 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_resource_usage.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/exportResourceUsage'} # type: ignore + @distributed_trace_async async def generate_upload_uri( self, resource_group_name: str, name: str, blob_name: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.GenerateUploadUriResponse": """Generate a URI for uploading custom disk images to a Lab. @@ -968,33 +902,22 @@ async def generate_upload_uri( } error_map.update(kwargs.pop('error_map', {})) - _generate_upload_uri_parameter = _models.GenerateUploadUriParameter(blob_name=blob_name) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.generate_upload_uri.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _generate_upload_uri_parameter = _models.GenerateUploadUriParameter(blob_name=blob_name) + _json = self._serialize.body(_generate_upload_uri_parameter, 'GenerateUploadUriParameter') + + request = build_generate_upload_uri_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.generate_upload_uri.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_generate_upload_uri_parameter, 'GenerateUploadUriParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1008,15 +931,17 @@ async def generate_upload_uri( return cls(pipeline_response, deserialized, {}) return deserialized + generate_upload_uri.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/generateUploadUri'} # type: ignore + async def _import_virtual_machine_initial( self, resource_group_name: str, name: str, source_virtual_machine_resource_id: Optional[str] = None, destination_virtual_machine_name: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -1024,33 +949,22 @@ async def _import_virtual_machine_initial( } error_map.update(kwargs.pop('error_map', {})) - _import_lab_virtual_machine_request = _models.ImportLabVirtualMachineRequest(source_virtual_machine_resource_id=source_virtual_machine_resource_id, destination_virtual_machine_name=destination_virtual_machine_name) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._import_virtual_machine_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _import_lab_virtual_machine_request = _models.ImportLabVirtualMachineRequest(source_virtual_machine_resource_id=source_virtual_machine_resource_id, destination_virtual_machine_name=destination_virtual_machine_name) + _json = self._serialize.body(_import_lab_virtual_machine_request, 'ImportLabVirtualMachineRequest') + + request = build_import_virtual_machine_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._import_virtual_machine_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_import_lab_virtual_machine_request, 'ImportLabVirtualMachineRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1063,13 +977,15 @@ async def _import_virtual_machine_initial( _import_virtual_machine_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/importVirtualMachine'} # type: ignore + + @distributed_trace_async async def begin_import_virtual_machine( self, resource_group_name: str, name: str, source_virtual_machine_resource_id: Optional[str] = None, destination_virtual_machine_name: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Import a virtual machine into a different lab. This operation can take a while to complete. @@ -1085,15 +1001,18 @@ async def begin_import_virtual_machine( :type destination_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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1106,24 +1025,18 @@ async def begin_import_virtual_machine( name=name, source_virtual_machine_resource_id=source_virtual_machine_resource_id, destination_virtual_machine_name=destination_virtual_machine_name, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1135,13 +1048,15 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_import_virtual_machine.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/importVirtualMachine'} # type: ignore + @distributed_trace def list_vhds( self, resource_group_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.LabVhdList"]: """List disk images available for custom image creation. @@ -1159,36 +1074,33 @@ def list_vhds( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_vhds.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_vhds_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self.list_vhds.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_vhds_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LabVhdList', pipeline_response) + deserialized = self._deserialize("LabVhdList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1206,6 +1118,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_notification_channels_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_notification_channels_operations.py index be21cb67a36a..a139dce7fad7 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_notification_channels_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_notification_channels_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.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._notification_channels_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_notify_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -49,7 +55,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.NotificationChannelList"]: """List notification channels in a given lab. @@ -67,8 +73,10 @@ def list( '$orderby=name desc'. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NotificationChannelList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.NotificationChannelList] + :return: An iterator like instance of either NotificationChannelList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.NotificationChannelList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationChannelList"] @@ -76,44 +84,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('NotificationChannelList', pipeline_response) + deserialized = self._deserialize("NotificationChannelList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,18 +136,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.NotificationChannel": """Get notification channel. @@ -164,30 +171,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -201,15 +197,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, lab_name: str, name: str, notification_channel: "_models.NotificationChannel", - **kwargs + **kwargs: Any ) -> "_models.NotificationChannel": """Create or replace an existing notification channel. @@ -231,33 +230,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(notification_channel, 'NotificationChannel') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(notification_channel, 'NotificationChannel') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -275,14 +264,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete notification channel. @@ -302,28 +294,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -336,13 +318,15 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, name: str, - notification_channel: "_models.NotificationChannelFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.NotificationChannel": """Allows modifying tags of notification channels. All other properties will be ignored. @@ -352,8 +336,8 @@ async def update( :type lab_name: str :param name: The name of the notification channel. :type name: str - :param notification_channel: A notification. - :type notification_channel: ~azure.mgmt.devtestlabs.models.NotificationChannelFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: NotificationChannel, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.NotificationChannel @@ -364,33 +348,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _notification_channel = _models.NotificationChannelFragment(tags=tags) + _json = self._serialize.body(_notification_channel, 'NotificationChannelFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(notification_channel, 'NotificationChannelFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -404,8 +379,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}'} # type: ignore + + @distributed_trace_async async def notify( self, resource_group_name: str, @@ -413,7 +391,7 @@ async def notify( name: str, event_name: Optional[Union[str, "_models.NotificationChannelEventType"]] = None, json_payload: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Send notification to provided channel. @@ -438,34 +416,23 @@ async def notify( } error_map.update(kwargs.pop('error_map', {})) - _notify_parameters = _models.NotifyParameters(event_name=event_name, json_payload=json_payload) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.notify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _notify_parameters = _models.NotifyParameters(event_name=event_name, json_payload=json_payload) + _json = self._serialize.body(_notify_parameters, 'NotifyParameters') + + request = build_notify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.notify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_notify_parameters, 'NotifyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -477,3 +444,4 @@ async def notify( return cls(pipeline_response, None, {}) notify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}/notify'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_operations.py index cbefde857aa9..32f378148905 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_operations.py @@ -5,16 +5,20 @@ # 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, Generic, Optional, TypeVar +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, location_name: str, name: str, - **kwargs + **kwargs: Any ) -> "_models.OperationResult": """Get operation. @@ -62,38 +67,34 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + location_name=location_name, + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + 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) - deserialized = self._deserialize('OperationResult', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize('OperationResult', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('OperationResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/locations/{locationName}/operations/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_policies_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_policies_operations.py index 86b3eeb89d69..2eac8085dede 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_policies_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_policies_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.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._policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -50,7 +56,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyList"]: """List policies in a given policy set. @@ -79,45 +85,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('PolicyList', pipeline_response) + deserialized = self._deserialize("PolicyList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -135,11 +139,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -147,7 +153,7 @@ async def get( policy_set_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Policy": """Get policy. @@ -171,31 +177,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,8 +204,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -218,7 +216,7 @@ async def create_or_update( policy_set_name: str, name: str, policy: "_models.Policy", - **kwargs + **kwargs: Any ) -> "_models.Policy": """Create or replace an existing policy. @@ -242,34 +240,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(policy, 'Policy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(policy, 'Policy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,15 +275,18 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, lab_name: str, policy_set_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete policy. @@ -317,29 +308,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -352,14 +333,16 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, policy_set_name: str, name: str, - policy: "_models.PolicyFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.Policy": """Allows modifying tags of policies. All other properties will be ignored. @@ -371,8 +354,8 @@ async def update( :type policy_set_name: str :param name: The name of the policy. :type name: str - :param policy: A Policy. - :type policy: ~azure.mgmt.devtestlabs.models.PolicyFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Policy, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Policy @@ -383,34 +366,25 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _policy = _models.PolicyFragment(tags=tags) + _json = self._serialize.body(_policy, 'PolicyFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(policy, 'PolicyFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -424,4 +398,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_policy_sets_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_policy_sets_operations.py index 1fc63e77dfc8..83a8fa8fb82e 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_policy_sets_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_policy_sets_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_sets_operations import build_evaluate_policies_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +44,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def evaluate_policies( self, resource_group_name: str, lab_name: str, name: str, policies: Optional[List["_models.EvaluatePoliciesProperties"]] = None, - **kwargs + **kwargs: Any ) -> "_models.EvaluatePoliciesResponse": """Evaluates lab policy. @@ -69,34 +74,23 @@ async def evaluate_policies( } error_map.update(kwargs.pop('error_map', {})) - _evaluate_policies_request = _models.EvaluatePoliciesRequest(policies=policies) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.evaluate_policies.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _evaluate_policies_request = _models.EvaluatePoliciesRequest(policies=policies) + _json = self._serialize.body(_evaluate_policies_request, 'EvaluatePoliciesRequest') + + request = build_evaluate_policies_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.evaluate_policies.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_evaluate_policies_request, 'EvaluatePoliciesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,4 +104,6 @@ async def evaluate_policies( return cls(pipeline_response, deserialized, {}) return deserialized + evaluate_policies.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{name}/evaluatePolicies'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_provider_operations_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_provider_operations_operations.py index abea508b6cca..9aa2da72efb6 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_provider_operations_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_provider_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.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._provider_operations_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ProviderOperationResult"]: """Result of the request to list REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.ProviderOperationResult] + :return: An iterator like instance of either ProviderOperationResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.ProviderOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationResult"] @@ -57,30 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + 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('ProviderOperationResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +103,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_schedules_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_schedules_operations.py index 5f2c79aea70d..80badde0484b 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_schedules_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_schedules_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._schedules_operations import build_create_or_update_request, build_delete_request, build_execute_request_initial, build_get_request, build_list_applicable_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -51,7 +57,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ScheduleList"]: """List schedules in a given lab. @@ -78,44 +84,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,18 +136,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Get schedule. @@ -166,30 +171,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -203,15 +197,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, lab_name: str, name: str, schedule: "_models.Schedule", - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Create or replace an existing schedule. @@ -233,33 +230,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(schedule, 'Schedule') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'Schedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,14 +264,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete schedule. @@ -304,28 +294,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -338,13 +318,15 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, name: str, - schedule: "_models.ScheduleFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.Schedule": """Allows modifying tags of schedules. All other properties will be ignored. @@ -354,8 +336,8 @@ async def update( :type lab_name: str :param name: The name of the schedule. :type name: str - :param schedule: A schedule. - :type schedule: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Schedule @@ -366,33 +348,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _schedule = _models.ScheduleFragment(tags=tags) + _json = self._serialize.body(_schedule, 'ScheduleFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'ScheduleFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -406,42 +379,34 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}'} # type: ignore + async def _execute_initial( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._execute_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_execute_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._execute_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -454,12 +419,14 @@ async def _execute_initial( _execute_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/execute'} # type: ignore + + @distributed_trace_async async def begin_execute( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Execute a schedule. This operation can take a while to complete. @@ -471,15 +438,17 @@ async def begin_execute( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -494,22 +463,14 @@ async def begin_execute( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -521,14 +482,16 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_execute.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/execute'} # type: ignore + @distributed_trace def list_applicable( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ScheduleList"]: """Lists all applicable schedules. @@ -548,37 +511,35 @@ def list_applicable( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_applicable.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_applicable_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.list_applicable.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_applicable_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -596,6 +557,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_secrets_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_secrets_operations.py index 880c4f793811..de0ac1a53f61 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_secrets_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_secrets_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._secrets_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -52,7 +58,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SecretList"]: """List secrets in a given user profile. @@ -81,45 +87,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('SecretList', pipeline_response) + deserialized = self._deserialize("SecretList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,11 +141,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,7 +155,7 @@ async def get( user_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Secret": """Get secret. @@ -173,31 +179,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +206,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -220,41 +217,31 @@ async def _create_or_update_initial( user_name: str, name: str, secret: "_models.Secret", - **kwargs + **kwargs: Any ) -> "_models.Secret": cls = kwargs.pop('cls', None) # type: ClsType["_models.Secret"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(secret, 'Secret') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(secret, 'Secret') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -272,8 +259,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -281,7 +271,7 @@ async def begin_create_or_update( user_name: str, name: str, secret: "_models.Secret", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.Secret"]: """Create or replace an existing secret. This operation can take a while to complete. @@ -297,15 +287,19 @@ async def begin_create_or_update( :type secret: ~azure.mgmt.devtestlabs.models.Secret :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Secret or the result of cls(response) + :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 Secret or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.Secret] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Secret"] lro_delay = kwargs.pop( 'polling_interval', @@ -319,29 +313,21 @@ async def begin_create_or_update( user_name=user_name, name=name, secret=secret, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Secret', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -353,15 +339,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + @distributed_trace_async async def delete( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete secret. @@ -383,29 +371,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -418,6 +396,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -425,8 +405,7 @@ async def update( user_name: str, name: str, tags: Optional[Dict[str, str]] = None, - value: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Secret": """Allows modifying tags of secrets. All other properties will be ignored. @@ -440,8 +419,6 @@ async def update( :type name: str :param tags: The tags of the resource. :type tags: dict[str, str] - :param value: The value of the secret for secret creation. - :type value: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Secret, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Secret @@ -453,35 +430,24 @@ async def update( } error_map.update(kwargs.pop('error_map', {})) - _secret = _models.SecretFragment(tags=tags, value=value) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _secret = _models.SecretFragment(tags=tags) + _json = self._serialize.body(_secret, 'SecretFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_secret, 'SecretFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -495,4 +461,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_fabric_schedules_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_fabric_schedules_operations.py index 1ed377f38b03..8ee2ce4ba05d 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_fabric_schedules_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_fabric_schedules_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._service_fabric_schedules_operations import build_create_or_update_request, build_delete_request, build_execute_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -53,7 +59,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ScheduleList"]: """List schedules in a given service fabric. @@ -84,46 +90,45 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -141,11 +146,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -154,7 +161,7 @@ async def get( service_fabric_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Get schedule. @@ -180,32 +187,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -219,8 +215,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -229,7 +228,7 @@ async def create_or_update( service_fabric_name: str, name: str, schedule: "_models.Schedule", - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Create or replace an existing schedule. @@ -255,35 +254,25 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(schedule, 'Schedule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'Schedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -301,8 +290,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -310,7 +302,7 @@ async def delete( user_name: str, service_fabric_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete schedule. @@ -334,30 +326,20 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,6 +352,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -377,8 +361,8 @@ async def update( user_name: str, service_fabric_name: str, name: str, - schedule: "_models.ScheduleFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.Schedule": """Allows modifying tags of schedules. All other properties will be ignored. @@ -392,8 +376,8 @@ async def update( :type service_fabric_name: str :param name: The name of the schedule. :type name: str - :param schedule: A schedule. - :type schedule: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Schedule @@ -404,35 +388,26 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _schedule = _models.ScheduleFragment(tags=tags) + _json = self._serialize.body(_schedule, 'ScheduleFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'ScheduleFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -446,8 +421,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}'} # type: ignore + async def _execute_initial( self, resource_group_name: str, @@ -455,37 +432,27 @@ async def _execute_initial( user_name: str, service_fabric_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._execute_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_execute_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + template_url=self._execute_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -498,6 +465,8 @@ async def _execute_initial( _execute_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}/execute'} # type: ignore + + @distributed_trace_async async def begin_execute( self, resource_group_name: str, @@ -505,7 +474,7 @@ async def begin_execute( user_name: str, service_fabric_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Execute a schedule. This operation can take a while to complete. @@ -521,15 +490,17 @@ async def begin_execute( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -546,24 +517,14 @@ async def begin_execute( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -575,4 +536,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_execute.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}/execute'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_fabrics_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_fabrics_operations.py index 4fa19e38d269..fa12e198cff2 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_fabrics_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_fabrics_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._service_fabrics_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_applicable_schedules_request, build_list_request, build_start_request_initial, build_stop_request_initial, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -52,7 +58,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ServiceFabricList"]: """List service fabrics in a given user profile. @@ -73,7 +79,8 @@ def list( :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServiceFabricList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.ServiceFabricList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.ServiceFabricList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceFabricList"] @@ -81,45 +88,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ServiceFabricList', pipeline_response) + deserialized = self._deserialize("ServiceFabricList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,11 +142,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,7 +156,7 @@ async def get( user_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.ServiceFabric": """Get service fabric. @@ -173,31 +180,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +207,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -220,41 +218,31 @@ async def _create_or_update_initial( user_name: str, name: str, service_fabric: "_models.ServiceFabric", - **kwargs + **kwargs: Any ) -> "_models.ServiceFabric": cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceFabric"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(service_fabric, 'ServiceFabric') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_fabric, 'ServiceFabric') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -272,8 +260,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -281,7 +272,7 @@ async def begin_create_or_update( user_name: str, name: str, service_fabric: "_models.ServiceFabric", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.ServiceFabric"]: """Create or replace an existing service fabric. This operation can take a while to complete. @@ -297,15 +288,19 @@ async def begin_create_or_update( :type service_fabric: ~azure.mgmt.devtestlabs.models.ServiceFabric :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ServiceFabric or the result of cls(response) + :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 ServiceFabric or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.ServiceFabric] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceFabric"] lro_delay = kwargs.pop( 'polling_interval', @@ -319,29 +314,21 @@ async def begin_create_or_update( user_name=user_name, name=name, service_fabric=service_fabric, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServiceFabric', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -353,6 +340,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore async def _delete_initial( @@ -361,36 +349,26 @@ async def _delete_initial( lab_name: str, user_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -403,13 +381,15 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete service fabric. This operation can take a while to complete. @@ -423,15 +403,17 @@ async def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -447,23 +429,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -475,16 +448,18 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - service_fabric: "_models.ServiceFabricFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.ServiceFabric": """Allows modifying tags of service fabrics. All other properties will be ignored. @@ -496,8 +471,8 @@ async def update( :type user_name: str :param name: The name of the service fabric. :type name: str - :param service_fabric: A Service Fabric. - :type service_fabric: ~azure.mgmt.devtestlabs.models.ServiceFabricFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceFabric, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.ServiceFabric @@ -508,34 +483,25 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _service_fabric = _models.ServiceFabricFragment(tags=tags) + _json = self._serialize.body(_service_fabric, 'ServiceFabricFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_fabric, 'ServiceFabricFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -549,15 +515,18 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + + @distributed_trace_async async def list_applicable_schedules( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - **kwargs + **kwargs: Any ) -> "_models.ApplicableSchedule": """Lists the applicable start/stop schedules, if any. @@ -579,29 +548,19 @@ async def list_applicable_schedules( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.list_applicable_schedules.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_applicable_schedules_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self.list_applicable_schedules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -615,44 +574,36 @@ async def list_applicable_schedules( return cls(pipeline_response, deserialized, {}) return deserialized + list_applicable_schedules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/listApplicableSchedules'} # type: ignore + async def _start_initial( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -665,13 +616,15 @@ async def _start_initial( _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/start'} # type: ignore + + @distributed_trace_async async def begin_start( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Start a service fabric. This operation can take a while to complete. @@ -685,15 +638,17 @@ async def begin_start( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -709,23 +664,14 @@ async def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -737,6 +683,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/start'} # type: ignore async def _stop_initial( @@ -745,36 +692,26 @@ async def _stop_initial( lab_name: str, user_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -787,13 +724,15 @@ async def _stop_initial( _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/stop'} # type: ignore + + @distributed_trace_async async def begin_stop( self, resource_group_name: str, lab_name: str, user_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Stop a service fabric This operation can take a while to complete. @@ -807,15 +746,17 @@ async def begin_stop( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -831,23 +772,14 @@ async def begin_stop( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -859,4 +791,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/stop'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_runners_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_runners_operations.py index e43f7fa34dac..facdff0b49af 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_runners_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_service_runners_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._service_runners_operations import build_create_or_update_request, build_delete_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,12 +44,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> "_models.ServiceRunner": """Get service runner. @@ -65,28 +70,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,15 +95,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, lab_name: str, name: str, service_runner: "_models.ServiceRunner", - **kwargs + **kwargs: Any ) -> "_models.ServiceRunner": """Create or replace an existing service runner. @@ -130,33 +128,23 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(service_runner, 'ServiceRunner') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_runner, 'ServiceRunner') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -174,14 +162,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete service runner. @@ -201,28 +192,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -234,3 +215,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_users_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_users_operations.py index 1705b9b08454..b8b95c342beb 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_users_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_users_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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._users_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -51,7 +57,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.UserList"]: """List user profiles in a given lab. @@ -78,44 +84,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,18 +136,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.User": """Get user profile. @@ -166,30 +171,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -203,48 +197,40 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, lab_name: str, name: str, user: "_models.User", - **kwargs + **kwargs: Any ) -> "_models.User": cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(user, 'User') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -262,15 +248,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, lab_name: str, name: str, user: "_models.User", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.User"]: """Create or replace an existing user profile. This operation can take a while to complete. @@ -284,15 +273,18 @@ async def begin_create_or_update( :type user: ~azure.mgmt.devtestlabs.models.User :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.User] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] lro_delay = kwargs.pop( 'polling_interval', @@ -305,28 +297,21 @@ async def begin_create_or_update( lab_name=lab_name, name=name, user=user, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('User', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -338,6 +323,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore async def _delete_initial( @@ -345,35 +331,25 @@ async def _delete_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -386,12 +362,14 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete user profile. This operation can take a while to complete. @@ -403,15 +381,17 @@ async def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -426,22 +406,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -453,15 +425,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, name: str, - user: "_models.UserFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.User": """Allows modifying tags of user profiles. All other properties will be ignored. @@ -471,8 +445,8 @@ async def update( :type lab_name: str :param name: The name of the user profile. :type name: str - :param user: Profile of a lab user. - :type user: ~azure.mgmt.devtestlabs.models.UserFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: User, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.User @@ -483,33 +457,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _user = _models.UserFragment(tags=tags) + _json = self._serialize.body(_user, 'UserFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'UserFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -523,4 +488,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_machine_schedules_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_machine_schedules_operations.py index dab93e3eb69b..5521833f532e 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_machine_schedules_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_machine_schedules_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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_schedules_operations import build_create_or_update_request, build_delete_request, build_execute_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -52,7 +58,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ScheduleList"]: """List schedules in a given virtual machine. @@ -81,45 +87,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,11 +141,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,7 +155,7 @@ async def get( virtual_machine_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Get schedule. @@ -173,31 +179,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +206,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -220,7 +218,7 @@ async def create_or_update( virtual_machine_name: str, name: str, schedule: "_models.Schedule", - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Create or replace an existing schedule. @@ -244,34 +242,24 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(schedule, 'Schedule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'Schedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -289,15 +277,18 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, lab_name: str, virtual_machine_name: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Delete schedule. @@ -319,29 +310,19 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -354,14 +335,16 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, virtual_machine_name: str, name: str, - schedule: "_models.ScheduleFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.Schedule": """Allows modifying tags of schedules. All other properties will be ignored. @@ -373,8 +356,8 @@ async def update( :type virtual_machine_name: str :param name: The name of the schedule. :type name: str - :param schedule: A schedule. - :type schedule: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Schedule @@ -385,34 +368,25 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _schedule = _models.ScheduleFragment(tags=tags) + _json = self._serialize.body(_schedule, 'ScheduleFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'ScheduleFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -426,44 +400,36 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}'} # type: ignore + async def _execute_initial( self, resource_group_name: str, lab_name: str, virtual_machine_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._execute_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_execute_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + template_url=self._execute_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -476,13 +442,15 @@ async def _execute_initial( _execute_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}/execute'} # type: ignore + + @distributed_trace_async async def begin_execute( self, resource_group_name: str, lab_name: str, virtual_machine_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Execute a schedule. This operation can take a while to complete. @@ -496,15 +464,17 @@ async def begin_execute( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -520,23 +490,14 @@ async def begin_execute( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -548,4 +509,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_execute.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}/execute'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_machines_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_machines_operations.py index b83ef07fa68b..896fcb4e3f9a 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_machines_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_machines_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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_add_data_disk_request_initial, build_apply_artifacts_request_initial, build_claim_request_initial, build_create_or_update_request_initial, build_delete_request_initial, build_detach_data_disk_request_initial, build_get_rdp_file_contents_request, build_get_request, build_list_applicable_schedules_request, build_list_request, build_redeploy_request_initial, build_resize_request_initial, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_transfer_disks_request_initial, build_un_claim_request_initial, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -51,7 +57,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.LabVirtualMachineList"]: """List virtual machines in a given lab. @@ -70,8 +76,10 @@ def list( '$orderby=name desc'. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LabVirtualMachineList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.LabVirtualMachineList] + :return: An iterator like instance of either LabVirtualMachineList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.LabVirtualMachineList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LabVirtualMachineList"] @@ -79,44 +87,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('LabVirtualMachineList', pipeline_response) + deserialized = self._deserialize("LabVirtualMachineList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -134,18 +139,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.LabVirtualMachine": """Get virtual machine. @@ -168,30 +175,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -205,48 +201,40 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, lab_name: str, name: str, lab_virtual_machine: "_models.LabVirtualMachine", - **kwargs + **kwargs: Any ) -> "_models.LabVirtualMachine": cls = kwargs.pop('cls', None) # type: ClsType["_models.LabVirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(lab_virtual_machine, 'LabVirtualMachine') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_virtual_machine, 'LabVirtualMachine') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -264,15 +252,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, lab_name: str, name: str, lab_virtual_machine: "_models.LabVirtualMachine", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.LabVirtualMachine"]: """Create or replace an existing virtual machine. This operation can take a while to complete. @@ -286,15 +277,19 @@ async def begin_create_or_update( :type lab_virtual_machine: ~azure.mgmt.devtestlabs.models.LabVirtualMachine :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either LabVirtualMachine or the result of cls(response) + :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 LabVirtualMachine or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.devtestlabs.models.LabVirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LabVirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,28 +302,21 @@ async def begin_create_or_update( lab_name=lab_name, name=name, lab_virtual_machine=lab_virtual_machine, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LabVirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -340,6 +328,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore async def _delete_initial( @@ -347,35 +336,25 @@ async def _delete_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -388,12 +367,14 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete virtual machine. This operation can take a while to complete. @@ -405,15 +386,17 @@ async def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -428,22 +411,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -455,15 +430,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, name: str, - lab_virtual_machine: "_models.LabVirtualMachineFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.LabVirtualMachine": """Allows modifying tags of virtual machines. All other properties will be ignored. @@ -473,8 +450,8 @@ async def update( :type lab_name: str :param name: The name of the virtual machine. :type name: str - :param lab_virtual_machine: A virtual machine. - :type lab_virtual_machine: ~azure.mgmt.devtestlabs.models.LabVirtualMachineFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: LabVirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.LabVirtualMachine @@ -485,33 +462,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _lab_virtual_machine = _models.LabVirtualMachineFragment(tags=tags) + _json = self._serialize.body(_lab_virtual_machine, 'LabVirtualMachineFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_virtual_machine, 'LabVirtualMachineFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -525,48 +493,40 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + async def _add_data_disk_initial( self, resource_group_name: str, lab_name: str, name: str, data_disk_properties: "_models.DataDiskProperties", - **kwargs + **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 = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._add_data_disk_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(data_disk_properties, 'DataDiskProperties') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_add_data_disk_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._add_data_disk_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_disk_properties, 'DataDiskProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -579,13 +539,15 @@ async def _add_data_disk_initial( _add_data_disk_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk'} # type: ignore + + @distributed_trace_async async def begin_add_data_disk( self, resource_group_name: str, lab_name: str, name: str, data_disk_properties: "_models.DataDiskProperties", - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Attach a new or existing data disk to virtual machine. This operation can take a while to complete. @@ -601,15 +563,18 @@ async def begin_add_data_disk( :type data_disk_properties: ~azure.mgmt.devtestlabs.models.DataDiskProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -622,25 +587,18 @@ async def begin_add_data_disk( lab_name=lab_name, name=name, data_disk_properties=data_disk_properties, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -652,6 +610,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_add_data_disk.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk'} # type: ignore async def _apply_artifacts_initial( @@ -660,7 +619,7 @@ async def _apply_artifacts_initial( lab_name: str, name: str, artifacts: Optional[List["_models.ArtifactInstallProperties"]] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -668,34 +627,23 @@ async def _apply_artifacts_initial( } error_map.update(kwargs.pop('error_map', {})) - _apply_artifacts_request = _models.ApplyArtifactsRequest(artifacts=artifacts) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._apply_artifacts_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _apply_artifacts_request = _models.ApplyArtifactsRequest(artifacts=artifacts) + _json = self._serialize.body(_apply_artifacts_request, 'ApplyArtifactsRequest') + + request = build_apply_artifacts_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._apply_artifacts_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_apply_artifacts_request, 'ApplyArtifactsRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -708,13 +656,15 @@ async def _apply_artifacts_initial( _apply_artifacts_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts'} # type: ignore + + @distributed_trace_async async def begin_apply_artifacts( self, resource_group_name: str, lab_name: str, name: str, artifacts: Optional[List["_models.ArtifactInstallProperties"]] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Apply artifacts to virtual machine. This operation can take a while to complete. @@ -728,15 +678,18 @@ async def begin_apply_artifacts( :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -749,25 +702,18 @@ async def begin_apply_artifacts( lab_name=lab_name, name=name, artifacts=artifacts, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -779,6 +725,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_apply_artifacts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts'} # type: ignore async def _claim_initial( @@ -786,35 +733,25 @@ async def _claim_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._claim_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_claim_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._claim_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -827,12 +764,14 @@ async def _claim_initial( _claim_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim'} # type: ignore + + @distributed_trace_async async def begin_claim( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Take ownership of an existing virtual machine This operation can take a while to complete. @@ -844,15 +783,17 @@ async def begin_claim( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -867,22 +808,14 @@ async def begin_claim( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -894,6 +827,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_claim.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim'} # type: ignore async def _detach_data_disk_initial( @@ -902,7 +836,7 @@ async def _detach_data_disk_initial( lab_name: str, name: str, existing_lab_disk_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -910,34 +844,23 @@ async def _detach_data_disk_initial( } error_map.update(kwargs.pop('error_map', {})) - _detach_data_disk_properties = _models.DetachDataDiskProperties(existing_lab_disk_id=existing_lab_disk_id) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._detach_data_disk_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _detach_data_disk_properties = _models.DetachDataDiskProperties(existing_lab_disk_id=existing_lab_disk_id) + _json = self._serialize.body(_detach_data_disk_properties, 'DetachDataDiskProperties') + + request = build_detach_data_disk_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._detach_data_disk_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_detach_data_disk_properties, 'DetachDataDiskProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -950,13 +873,15 @@ async def _detach_data_disk_initial( _detach_data_disk_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk'} # type: ignore + + @distributed_trace_async async def begin_detach_data_disk( self, resource_group_name: str, lab_name: str, name: str, existing_lab_disk_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Detach the specified disk from the virtual machine. This operation can take a while to complete. @@ -971,15 +896,18 @@ async def begin_detach_data_disk( :type existing_lab_disk_id: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -992,25 +920,18 @@ async def begin_detach_data_disk( lab_name=lab_name, name=name, existing_lab_disk_id=existing_lab_disk_id, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1022,14 +943,16 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_detach_data_disk.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk'} # type: ignore + @distributed_trace_async async def get_rdp_file_contents( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> "_models.RdpConnection": """Gets a string that represents the contents of the RDP file for the virtual machine. @@ -1049,28 +972,18 @@ async def get_rdp_file_contents( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get_rdp_file_contents.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_rdp_file_contents_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.get_rdp_file_contents.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1084,14 +997,17 @@ async def get_rdp_file_contents( return cls(pipeline_response, deserialized, {}) return deserialized + get_rdp_file_contents.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/getRdpFileContents'} # type: ignore + + @distributed_trace_async async def list_applicable_schedules( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> "_models.ApplicableSchedule": """Lists the applicable start/stop schedules, if any. @@ -1111,28 +1027,18 @@ async def list_applicable_schedules( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.list_applicable_schedules.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_applicable_schedules_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.list_applicable_schedules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1146,42 +1052,34 @@ async def list_applicable_schedules( return cls(pipeline_response, deserialized, {}) return deserialized + list_applicable_schedules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/listApplicableSchedules'} # type: ignore + async def _redeploy_initial( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._redeploy_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_redeploy_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._redeploy_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1194,12 +1092,14 @@ async def _redeploy_initial( _redeploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/redeploy'} # type: ignore + + @distributed_trace_async async def begin_redeploy( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Redeploy a virtual machine This operation can take a while to complete. @@ -1211,15 +1111,17 @@ async def begin_redeploy( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1234,22 +1136,14 @@ async def begin_redeploy( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1261,6 +1155,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_redeploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/redeploy'} # type: ignore async def _resize_initial( @@ -1269,7 +1164,7 @@ async def _resize_initial( lab_name: str, name: str, size: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -1277,34 +1172,23 @@ async def _resize_initial( } error_map.update(kwargs.pop('error_map', {})) - _resize_lab_virtual_machine_properties = _models.ResizeLabVirtualMachineProperties(size=size) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._resize_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _resize_lab_virtual_machine_properties = _models.ResizeLabVirtualMachineProperties(size=size) + _json = self._serialize.body(_resize_lab_virtual_machine_properties, 'ResizeLabVirtualMachineProperties') + + request = build_resize_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._resize_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_resize_lab_virtual_machine_properties, 'ResizeLabVirtualMachineProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1317,13 +1201,15 @@ async def _resize_initial( _resize_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/resize'} # type: ignore + + @distributed_trace_async async def begin_resize( self, resource_group_name: str, lab_name: str, name: str, size: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Resize Virtual Machine. This operation can take a while to complete. @@ -1337,15 +1223,18 @@ async def begin_resize( :type size: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1358,25 +1247,18 @@ async def begin_resize( lab_name=lab_name, name=name, size=size, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1388,6 +1270,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_resize.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/resize'} # type: ignore async def _restart_initial( @@ -1395,35 +1278,25 @@ async def _restart_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._restart_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_restart_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._restart_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1436,12 +1309,14 @@ async def _restart_initial( _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/restart'} # type: ignore + + @distributed_trace_async async def begin_restart( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Restart a virtual machine. This operation can take a while to complete. @@ -1453,15 +1328,17 @@ async def begin_restart( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1476,22 +1353,14 @@ async def begin_restart( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1503,6 +1372,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/restart'} # type: ignore async def _start_initial( @@ -1510,35 +1380,25 @@ async def _start_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1551,12 +1411,14 @@ async def _start_initial( _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start'} # type: ignore + + @distributed_trace_async async def begin_start( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Start a virtual machine. This operation can take a while to complete. @@ -1568,15 +1430,17 @@ async def begin_start( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1591,22 +1455,14 @@ async def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1618,6 +1474,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start'} # type: ignore async def _stop_initial( @@ -1625,35 +1482,25 @@ async def _stop_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1666,12 +1513,14 @@ async def _stop_initial( _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop'} # type: ignore + + @distributed_trace_async async def begin_stop( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Stop a virtual machine This operation can take a while to complete. @@ -1683,15 +1532,17 @@ async def begin_stop( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1706,22 +1557,14 @@ async def begin_stop( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1733,6 +1576,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop'} # type: ignore async def _transfer_disks_initial( @@ -1740,35 +1584,25 @@ async def _transfer_disks_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._transfer_disks_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_transfer_disks_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._transfer_disks_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1781,12 +1615,14 @@ async def _transfer_disks_initial( _transfer_disks_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/transferDisks'} # type: ignore + + @distributed_trace_async async def begin_transfer_disks( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Transfers all data disks attached to the virtual machine to be owned by the current user. This operation can take a while to complete. @@ -1799,15 +1635,17 @@ async def begin_transfer_disks( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1822,22 +1660,14 @@ async def begin_transfer_disks( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1849,6 +1679,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_transfer_disks.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/transferDisks'} # type: ignore async def _un_claim_initial( @@ -1856,35 +1687,25 @@ async def _un_claim_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._un_claim_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_un_claim_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._un_claim_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1897,12 +1718,14 @@ async def _un_claim_initial( _un_claim_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/unClaim'} # type: ignore + + @distributed_trace_async async def begin_un_claim( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Release ownership of an existing virtual machine This operation can take a while to complete. @@ -1914,15 +1737,17 @@ async def begin_un_claim( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1937,22 +1762,14 @@ async def begin_un_claim( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1964,4 +1781,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_un_claim.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/unClaim'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_networks_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_networks_operations.py index 624b20adfe4c..05a7ac9d2f95 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_networks_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/aio/operations/_virtual_networks_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -51,7 +57,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.VirtualNetworkList"]: """List virtual networks in a given lab. @@ -70,7 +76,8 @@ def list( :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualNetworkList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.VirtualNetworkList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devtestlabs.models.VirtualNetworkList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkList"] @@ -78,44 +85,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('VirtualNetworkList', pipeline_response) + deserialized = self._deserialize("VirtualNetworkList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,18 +137,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, lab_name: str, name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.VirtualNetwork": """Get virtual network. @@ -166,30 +172,19 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -203,48 +198,40 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, lab_name: str, name: str, virtual_network: "_models.VirtualNetwork", - **kwargs + **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 = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(virtual_network, 'VirtualNetwork') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(virtual_network, 'VirtualNetwork') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -262,15 +249,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, lab_name: str, name: str, virtual_network: "_models.VirtualNetwork", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.VirtualNetwork"]: """Create or replace an existing virtual network. This operation can take a while to complete. @@ -284,15 +274,19 @@ async def begin_create_or_update( :type virtual_network: ~azure.mgmt.devtestlabs.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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualNetwork or the result of cls(response) + :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.devtestlabs.models.VirtualNetwork] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] lro_delay = kwargs.pop( 'polling_interval', @@ -305,28 +299,21 @@ async def begin_create_or_update( lab_name=lab_name, name=name, virtual_network=virtual_network, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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 - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -338,6 +325,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore async def _delete_initial( @@ -345,35 +333,25 @@ async def _delete_initial( resource_group_name: str, lab_name: str, name: str, - **kwargs + **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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -386,12 +364,14 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, lab_name: str, name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete virtual network. This operation can take a while to complete. @@ -403,15 +383,17 @@ async def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -426,22 +408,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -453,15 +427,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, lab_name: str, name: str, - virtual_network: "_models.VirtualNetworkFragment", - **kwargs + tags: Optional[Dict[str, str]] = None, + **kwargs: Any ) -> "_models.VirtualNetwork": """Allows modifying tags of virtual networks. All other properties will be ignored. @@ -471,8 +447,8 @@ async def update( :type lab_name: str :param name: The name of the virtual network. :type name: str - :param virtual_network: A virtual network. - :type virtual_network: ~azure.mgmt.devtestlabs.models.VirtualNetworkFragment + :param tags: The tags of the resource. + :type tags: dict[str, 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.devtestlabs.models.VirtualNetwork @@ -483,33 +459,24 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _virtual_network = _models.VirtualNetworkFragment(tags=tags) + _json = self._serialize.body(_virtual_network, 'VirtualNetworkFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(virtual_network, 'VirtualNetworkFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -523,4 +490,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/__init__.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/__init__.py index 4018a95629c3..e28b759ce764 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/__init__.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/__init__.py @@ -6,342 +6,137 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ApplicableSchedule - from ._models_py3 import ApplicableScheduleFragment - from ._models_py3 import ApplyArtifactsRequest - from ._models_py3 import ArmTemplate - from ._models_py3 import ArmTemplateInfo - from ._models_py3 import ArmTemplateList - from ._models_py3 import ArmTemplateParameterProperties - from ._models_py3 import ArmTemplateParameterPropertiesFragment - from ._models_py3 import Artifact - from ._models_py3 import ArtifactDeploymentStatusProperties - from ._models_py3 import ArtifactDeploymentStatusPropertiesFragment - from ._models_py3 import ArtifactInstallProperties - from ._models_py3 import ArtifactInstallPropertiesFragment - from ._models_py3 import ArtifactList - from ._models_py3 import ArtifactParameterProperties - from ._models_py3 import ArtifactParameterPropertiesFragment - from ._models_py3 import ArtifactSource - from ._models_py3 import ArtifactSourceFragment - from ._models_py3 import ArtifactSourceList - from ._models_py3 import AttachDiskProperties - from ._models_py3 import AttachNewDataDiskOptions - from ._models_py3 import AttachNewDataDiskOptionsFragment - from ._models_py3 import BulkCreationParameters - from ._models_py3 import BulkCreationParametersFragment - from ._models_py3 import CloudErrorBody - from ._models_py3 import ComputeDataDisk - from ._models_py3 import ComputeDataDiskFragment - from ._models_py3 import ComputeVmInstanceViewStatus - from ._models_py3 import ComputeVmInstanceViewStatusFragment - from ._models_py3 import ComputeVmProperties - from ._models_py3 import ComputeVmPropertiesFragment - from ._models_py3 import CostThresholdProperties - from ._models_py3 import CustomImage - from ._models_py3 import CustomImageFragment - from ._models_py3 import CustomImageList - from ._models_py3 import CustomImagePropertiesCustom - from ._models_py3 import CustomImagePropertiesCustomFragment - from ._models_py3 import CustomImagePropertiesFromPlan - from ._models_py3 import CustomImagePropertiesFromPlanFragment - from ._models_py3 import CustomImagePropertiesFromVm - from ._models_py3 import CustomImagePropertiesFromVmFragment - from ._models_py3 import DataDiskProperties - from ._models_py3 import DataDiskPropertiesFragment - from ._models_py3 import DataDiskStorageTypeInfo - from ._models_py3 import DataDiskStorageTypeInfoFragment - from ._models_py3 import DayDetails - from ._models_py3 import DayDetailsFragment - from ._models_py3 import DetachDataDiskProperties - from ._models_py3 import DetachDiskProperties - from ._models_py3 import Disk - from ._models_py3 import DiskFragment - from ._models_py3 import DiskList - from ._models_py3 import DtlEnvironment - from ._models_py3 import DtlEnvironmentFragment - from ._models_py3 import DtlEnvironmentList - from ._models_py3 import EnvironmentDeploymentProperties - from ._models_py3 import EnvironmentDeploymentPropertiesFragment - from ._models_py3 import EvaluatePoliciesProperties - from ._models_py3 import EvaluatePoliciesRequest - from ._models_py3 import EvaluatePoliciesResponse - from ._models_py3 import Event - from ._models_py3 import EventFragment - from ._models_py3 import ExportResourceUsageParameters - from ._models_py3 import ExternalSubnet - from ._models_py3 import ExternalSubnetFragment - from ._models_py3 import Formula - from ._models_py3 import FormulaFragment - from ._models_py3 import FormulaList - from ._models_py3 import FormulaPropertiesFromVm - from ._models_py3 import FormulaPropertiesFromVmFragment - from ._models_py3 import GalleryImage - from ._models_py3 import GalleryImageList - from ._models_py3 import GalleryImageReference - from ._models_py3 import GalleryImageReferenceFragment - from ._models_py3 import GenerateArmTemplateRequest - from ._models_py3 import GenerateUploadUriParameter - from ._models_py3 import GenerateUploadUriResponse - from ._models_py3 import HourDetails - from ._models_py3 import HourDetailsFragment - from ._models_py3 import IdentityProperties - from ._models_py3 import ImportLabVirtualMachineRequest - from ._models_py3 import InboundNatRule - from ._models_py3 import InboundNatRuleFragment - from ._models_py3 import Lab - from ._models_py3 import LabAnnouncementProperties - from ._models_py3 import LabAnnouncementPropertiesFragment - from ._models_py3 import LabCost - from ._models_py3 import LabCostDetailsProperties - from ._models_py3 import LabCostSummaryProperties - from ._models_py3 import LabFragment - from ._models_py3 import LabList - from ._models_py3 import LabResourceCostProperties - from ._models_py3 import LabSupportProperties - from ._models_py3 import LabSupportPropertiesFragment - from ._models_py3 import LabVhd - from ._models_py3 import LabVhdList - from ._models_py3 import LabVirtualMachine - from ._models_py3 import LabVirtualMachineCreationParameter - from ._models_py3 import LabVirtualMachineCreationParameterFragment - from ._models_py3 import LabVirtualMachineFragment - from ._models_py3 import LabVirtualMachineList - from ._models_py3 import LinuxOsInfo - from ._models_py3 import LinuxOsInfoFragment - from ._models_py3 import NetworkInterfaceProperties - from ._models_py3 import NetworkInterfacePropertiesFragment - from ._models_py3 import NotificationChannel - from ._models_py3 import NotificationChannelFragment - from ._models_py3 import NotificationChannelList - from ._models_py3 import NotificationSettings - from ._models_py3 import NotificationSettingsFragment - from ._models_py3 import NotifyParameters - from ._models_py3 import OperationError - from ._models_py3 import OperationMetadata - from ._models_py3 import OperationMetadataDisplay - from ._models_py3 import OperationResult - from ._models_py3 import ParameterInfo - from ._models_py3 import ParametersValueFileInfo - from ._models_py3 import PercentageCostThresholdProperties - from ._models_py3 import Policy - from ._models_py3 import PolicyFragment - from ._models_py3 import PolicyList - from ._models_py3 import PolicySetResult - from ._models_py3 import PolicyViolation - from ._models_py3 import Port - from ._models_py3 import PortFragment - from ._models_py3 import ProviderOperationResult - from ._models_py3 import RdpConnection - from ._models_py3 import ResizeLabVirtualMachineProperties - from ._models_py3 import Resource - from ._models_py3 import RetargetScheduleProperties - from ._models_py3 import Schedule - from ._models_py3 import ScheduleCreationParameter - from ._models_py3 import ScheduleCreationParameterFragment - from ._models_py3 import ScheduleFragment - from ._models_py3 import ScheduleList - from ._models_py3 import Secret - from ._models_py3 import SecretFragment - from ._models_py3 import SecretList - from ._models_py3 import ServiceFabric - from ._models_py3 import ServiceFabricFragment - from ._models_py3 import ServiceFabricList - from ._models_py3 import ServiceRunner - from ._models_py3 import SharedPublicIpAddressConfiguration - from ._models_py3 import SharedPublicIpAddressConfigurationFragment - from ._models_py3 import ShutdownNotificationContent - from ._models_py3 import Subnet - from ._models_py3 import SubnetFragment - from ._models_py3 import SubnetOverride - from ._models_py3 import SubnetOverrideFragment - from ._models_py3 import SubnetSharedPublicIpAddressConfiguration - from ._models_py3 import SubnetSharedPublicIpAddressConfigurationFragment - from ._models_py3 import TargetCostProperties - from ._models_py3 import UpdateResource - from ._models_py3 import User - from ._models_py3 import UserFragment - from ._models_py3 import UserIdentity - from ._models_py3 import UserIdentityFragment - from ._models_py3 import UserList - from ._models_py3 import UserSecretStore - from ._models_py3 import UserSecretStoreFragment - from ._models_py3 import VirtualNetwork - from ._models_py3 import VirtualNetworkFragment - from ._models_py3 import VirtualNetworkList - from ._models_py3 import WeekDetails - from ._models_py3 import WeekDetailsFragment - from ._models_py3 import WindowsOsInfo - from ._models_py3 import WindowsOsInfoFragment -except (SyntaxError, ImportError): - from ._models import ApplicableSchedule # type: ignore - from ._models import ApplicableScheduleFragment # type: ignore - from ._models import ApplyArtifactsRequest # type: ignore - from ._models import ArmTemplate # type: ignore - from ._models import ArmTemplateInfo # type: ignore - from ._models import ArmTemplateList # type: ignore - from ._models import ArmTemplateParameterProperties # type: ignore - from ._models import ArmTemplateParameterPropertiesFragment # type: ignore - from ._models import Artifact # type: ignore - from ._models import ArtifactDeploymentStatusProperties # type: ignore - from ._models import ArtifactDeploymentStatusPropertiesFragment # type: ignore - from ._models import ArtifactInstallProperties # type: ignore - from ._models import ArtifactInstallPropertiesFragment # type: ignore - from ._models import ArtifactList # type: ignore - from ._models import ArtifactParameterProperties # type: ignore - from ._models import ArtifactParameterPropertiesFragment # type: ignore - from ._models import ArtifactSource # type: ignore - from ._models import ArtifactSourceFragment # type: ignore - from ._models import ArtifactSourceList # type: ignore - from ._models import AttachDiskProperties # type: ignore - from ._models import AttachNewDataDiskOptions # type: ignore - from ._models import AttachNewDataDiskOptionsFragment # type: ignore - from ._models import BulkCreationParameters # type: ignore - from ._models import BulkCreationParametersFragment # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import ComputeDataDisk # type: ignore - from ._models import ComputeDataDiskFragment # type: ignore - from ._models import ComputeVmInstanceViewStatus # type: ignore - from ._models import ComputeVmInstanceViewStatusFragment # type: ignore - from ._models import ComputeVmProperties # type: ignore - from ._models import ComputeVmPropertiesFragment # type: ignore - from ._models import CostThresholdProperties # type: ignore - from ._models import CustomImage # type: ignore - from ._models import CustomImageFragment # type: ignore - from ._models import CustomImageList # type: ignore - from ._models import CustomImagePropertiesCustom # type: ignore - from ._models import CustomImagePropertiesCustomFragment # type: ignore - from ._models import CustomImagePropertiesFromPlan # type: ignore - from ._models import CustomImagePropertiesFromPlanFragment # type: ignore - from ._models import CustomImagePropertiesFromVm # type: ignore - from ._models import CustomImagePropertiesFromVmFragment # type: ignore - from ._models import DataDiskProperties # type: ignore - from ._models import DataDiskPropertiesFragment # type: ignore - from ._models import DataDiskStorageTypeInfo # type: ignore - from ._models import DataDiskStorageTypeInfoFragment # type: ignore - from ._models import DayDetails # type: ignore - from ._models import DayDetailsFragment # type: ignore - from ._models import DetachDataDiskProperties # type: ignore - from ._models import DetachDiskProperties # type: ignore - from ._models import Disk # type: ignore - from ._models import DiskFragment # type: ignore - from ._models import DiskList # type: ignore - from ._models import DtlEnvironment # type: ignore - from ._models import DtlEnvironmentFragment # type: ignore - from ._models import DtlEnvironmentList # type: ignore - from ._models import EnvironmentDeploymentProperties # type: ignore - from ._models import EnvironmentDeploymentPropertiesFragment # type: ignore - from ._models import EvaluatePoliciesProperties # type: ignore - from ._models import EvaluatePoliciesRequest # type: ignore - from ._models import EvaluatePoliciesResponse # type: ignore - from ._models import Event # type: ignore - from ._models import EventFragment # type: ignore - from ._models import ExportResourceUsageParameters # type: ignore - from ._models import ExternalSubnet # type: ignore - from ._models import ExternalSubnetFragment # type: ignore - from ._models import Formula # type: ignore - from ._models import FormulaFragment # type: ignore - from ._models import FormulaList # type: ignore - from ._models import FormulaPropertiesFromVm # type: ignore - from ._models import FormulaPropertiesFromVmFragment # type: ignore - from ._models import GalleryImage # type: ignore - from ._models import GalleryImageList # type: ignore - from ._models import GalleryImageReference # type: ignore - from ._models import GalleryImageReferenceFragment # type: ignore - from ._models import GenerateArmTemplateRequest # type: ignore - from ._models import GenerateUploadUriParameter # type: ignore - from ._models import GenerateUploadUriResponse # type: ignore - from ._models import HourDetails # type: ignore - from ._models import HourDetailsFragment # type: ignore - from ._models import IdentityProperties # type: ignore - from ._models import ImportLabVirtualMachineRequest # type: ignore - from ._models import InboundNatRule # type: ignore - from ._models import InboundNatRuleFragment # type: ignore - from ._models import Lab # type: ignore - from ._models import LabAnnouncementProperties # type: ignore - from ._models import LabAnnouncementPropertiesFragment # type: ignore - from ._models import LabCost # type: ignore - from ._models import LabCostDetailsProperties # type: ignore - from ._models import LabCostSummaryProperties # type: ignore - from ._models import LabFragment # type: ignore - from ._models import LabList # type: ignore - from ._models import LabResourceCostProperties # type: ignore - from ._models import LabSupportProperties # type: ignore - from ._models import LabSupportPropertiesFragment # type: ignore - from ._models import LabVhd # type: ignore - from ._models import LabVhdList # type: ignore - from ._models import LabVirtualMachine # type: ignore - from ._models import LabVirtualMachineCreationParameter # type: ignore - from ._models import LabVirtualMachineCreationParameterFragment # type: ignore - from ._models import LabVirtualMachineFragment # type: ignore - from ._models import LabVirtualMachineList # type: ignore - from ._models import LinuxOsInfo # type: ignore - from ._models import LinuxOsInfoFragment # type: ignore - from ._models import NetworkInterfaceProperties # type: ignore - from ._models import NetworkInterfacePropertiesFragment # type: ignore - from ._models import NotificationChannel # type: ignore - from ._models import NotificationChannelFragment # type: ignore - from ._models import NotificationChannelList # type: ignore - from ._models import NotificationSettings # type: ignore - from ._models import NotificationSettingsFragment # type: ignore - from ._models import NotifyParameters # type: ignore - from ._models import OperationError # type: ignore - from ._models import OperationMetadata # type: ignore - from ._models import OperationMetadataDisplay # type: ignore - from ._models import OperationResult # type: ignore - from ._models import ParameterInfo # type: ignore - from ._models import ParametersValueFileInfo # type: ignore - from ._models import PercentageCostThresholdProperties # type: ignore - from ._models import Policy # type: ignore - from ._models import PolicyFragment # type: ignore - from ._models import PolicyList # type: ignore - from ._models import PolicySetResult # type: ignore - from ._models import PolicyViolation # type: ignore - from ._models import Port # type: ignore - from ._models import PortFragment # type: ignore - from ._models import ProviderOperationResult # type: ignore - from ._models import RdpConnection # type: ignore - from ._models import ResizeLabVirtualMachineProperties # type: ignore - from ._models import Resource # type: ignore - from ._models import RetargetScheduleProperties # type: ignore - from ._models import Schedule # type: ignore - from ._models import ScheduleCreationParameter # type: ignore - from ._models import ScheduleCreationParameterFragment # type: ignore - from ._models import ScheduleFragment # type: ignore - from ._models import ScheduleList # type: ignore - from ._models import Secret # type: ignore - from ._models import SecretFragment # type: ignore - from ._models import SecretList # type: ignore - from ._models import ServiceFabric # type: ignore - from ._models import ServiceFabricFragment # type: ignore - from ._models import ServiceFabricList # type: ignore - from ._models import ServiceRunner # type: ignore - from ._models import SharedPublicIpAddressConfiguration # type: ignore - from ._models import SharedPublicIpAddressConfigurationFragment # type: ignore - from ._models import ShutdownNotificationContent # type: ignore - from ._models import Subnet # type: ignore - from ._models import SubnetFragment # type: ignore - from ._models import SubnetOverride # type: ignore - from ._models import SubnetOverrideFragment # type: ignore - from ._models import SubnetSharedPublicIpAddressConfiguration # type: ignore - from ._models import SubnetSharedPublicIpAddressConfigurationFragment # type: ignore - from ._models import TargetCostProperties # type: ignore - from ._models import UpdateResource # type: ignore - from ._models import User # type: ignore - from ._models import UserFragment # type: ignore - from ._models import UserIdentity # type: ignore - from ._models import UserIdentityFragment # type: ignore - from ._models import UserList # type: ignore - from ._models import UserSecretStore # type: ignore - from ._models import UserSecretStoreFragment # type: ignore - from ._models import VirtualNetwork # type: ignore - from ._models import VirtualNetworkFragment # type: ignore - from ._models import VirtualNetworkList # type: ignore - from ._models import WeekDetails # type: ignore - from ._models import WeekDetailsFragment # type: ignore - from ._models import WindowsOsInfo # type: ignore - from ._models import WindowsOsInfoFragment # type: ignore +from ._models_py3 import ApplicableSchedule +from ._models_py3 import ApplicableScheduleFragment +from ._models_py3 import ApplyArtifactsRequest +from ._models_py3 import ArmTemplate +from ._models_py3 import ArmTemplateInfo +from ._models_py3 import ArmTemplateList +from ._models_py3 import ArmTemplateParameterProperties +from ._models_py3 import Artifact +from ._models_py3 import ArtifactDeploymentStatusProperties +from ._models_py3 import ArtifactInstallProperties +from ._models_py3 import ArtifactList +from ._models_py3 import ArtifactParameterProperties +from ._models_py3 import ArtifactSource +from ._models_py3 import ArtifactSourceFragment +from ._models_py3 import ArtifactSourceList +from ._models_py3 import AttachDiskProperties +from ._models_py3 import AttachNewDataDiskOptions +from ._models_py3 import BulkCreationParameters +from ._models_py3 import CloudErrorBody +from ._models_py3 import ComputeDataDisk +from ._models_py3 import ComputeVmInstanceViewStatus +from ._models_py3 import ComputeVmProperties +from ._models_py3 import CostThresholdProperties +from ._models_py3 import CustomImage +from ._models_py3 import CustomImageFragment +from ._models_py3 import CustomImageList +from ._models_py3 import CustomImagePropertiesCustom +from ._models_py3 import CustomImagePropertiesFromPlan +from ._models_py3 import CustomImagePropertiesFromVm +from ._models_py3 import DataDiskProperties +from ._models_py3 import DataDiskStorageTypeInfo +from ._models_py3 import DayDetails +from ._models_py3 import DetachDataDiskProperties +from ._models_py3 import DetachDiskProperties +from ._models_py3 import Disk +from ._models_py3 import DiskFragment +from ._models_py3 import DiskList +from ._models_py3 import DtlEnvironment +from ._models_py3 import DtlEnvironmentFragment +from ._models_py3 import DtlEnvironmentList +from ._models_py3 import EnvironmentDeploymentProperties +from ._models_py3 import EvaluatePoliciesProperties +from ._models_py3 import EvaluatePoliciesRequest +from ._models_py3 import EvaluatePoliciesResponse +from ._models_py3 import Event +from ._models_py3 import ExportResourceUsageParameters +from ._models_py3 import ExternalSubnet +from ._models_py3 import Formula +from ._models_py3 import FormulaFragment +from ._models_py3 import FormulaList +from ._models_py3 import FormulaPropertiesFromVm +from ._models_py3 import GalleryImage +from ._models_py3 import GalleryImageList +from ._models_py3 import GalleryImageReference +from ._models_py3 import GenerateArmTemplateRequest +from ._models_py3 import GenerateUploadUriParameter +from ._models_py3 import GenerateUploadUriResponse +from ._models_py3 import HourDetails +from ._models_py3 import IdentityProperties +from ._models_py3 import ImportLabVirtualMachineRequest +from ._models_py3 import InboundNatRule +from ._models_py3 import Lab +from ._models_py3 import LabAnnouncementProperties +from ._models_py3 import LabCost +from ._models_py3 import LabCostDetailsProperties +from ._models_py3 import LabCostSummaryProperties +from ._models_py3 import LabFragment +from ._models_py3 import LabList +from ._models_py3 import LabResourceCostProperties +from ._models_py3 import LabSupportProperties +from ._models_py3 import LabVhd +from ._models_py3 import LabVhdList +from ._models_py3 import LabVirtualMachine +from ._models_py3 import LabVirtualMachineCreationParameter +from ._models_py3 import LabVirtualMachineFragment +from ._models_py3 import LabVirtualMachineList +from ._models_py3 import LinuxOsInfo +from ._models_py3 import NetworkInterfaceProperties +from ._models_py3 import NotificationChannel +from ._models_py3 import NotificationChannelFragment +from ._models_py3 import NotificationChannelList +from ._models_py3 import NotificationSettings +from ._models_py3 import NotifyParameters +from ._models_py3 import OperationError +from ._models_py3 import OperationMetadata +from ._models_py3 import OperationMetadataDisplay +from ._models_py3 import OperationResult +from ._models_py3 import ParameterInfo +from ._models_py3 import ParametersValueFileInfo +from ._models_py3 import PercentageCostThresholdProperties +from ._models_py3 import Policy +from ._models_py3 import PolicyFragment +from ._models_py3 import PolicyList +from ._models_py3 import PolicySetResult +from ._models_py3 import PolicyViolation +from ._models_py3 import Port +from ._models_py3 import ProviderOperationResult +from ._models_py3 import RdpConnection +from ._models_py3 import ResizeLabVirtualMachineProperties +from ._models_py3 import Resource +from ._models_py3 import RetargetScheduleProperties +from ._models_py3 import Schedule +from ._models_py3 import ScheduleCreationParameter +from ._models_py3 import ScheduleFragment +from ._models_py3 import ScheduleList +from ._models_py3 import Secret +from ._models_py3 import SecretFragment +from ._models_py3 import SecretList +from ._models_py3 import ServiceFabric +from ._models_py3 import ServiceFabricFragment +from ._models_py3 import ServiceFabricList +from ._models_py3 import ServiceRunner +from ._models_py3 import ServiceRunnerList +from ._models_py3 import SharedPublicIpAddressConfiguration +from ._models_py3 import ShutdownNotificationContent +from ._models_py3 import Subnet +from ._models_py3 import SubnetOverride +from ._models_py3 import SubnetSharedPublicIpAddressConfiguration +from ._models_py3 import TargetCostProperties +from ._models_py3 import UpdateResource +from ._models_py3 import User +from ._models_py3 import UserFragment +from ._models_py3 import UserIdentity +from ._models_py3 import UserList +from ._models_py3 import UserSecretStore +from ._models_py3 import VirtualNetwork +from ._models_py3 import VirtualNetworkFragment +from ._models_py3 import VirtualNetworkList +from ._models_py3 import WeekDetails +from ._models_py3 import WindowsOsInfo + from ._dev_test_labs_client_enums import ( CostThresholdStatus, @@ -353,6 +148,7 @@ HostCachingOptions, HttpStatusCode, LinuxOsState, + ManagedIdentityType, NotificationChannelEventType, PolicyEvaluatorType, PolicyFactName, @@ -376,46 +172,31 @@ 'ArmTemplateInfo', 'ArmTemplateList', 'ArmTemplateParameterProperties', - 'ArmTemplateParameterPropertiesFragment', 'Artifact', 'ArtifactDeploymentStatusProperties', - 'ArtifactDeploymentStatusPropertiesFragment', 'ArtifactInstallProperties', - 'ArtifactInstallPropertiesFragment', 'ArtifactList', 'ArtifactParameterProperties', - 'ArtifactParameterPropertiesFragment', 'ArtifactSource', 'ArtifactSourceFragment', 'ArtifactSourceList', 'AttachDiskProperties', 'AttachNewDataDiskOptions', - 'AttachNewDataDiskOptionsFragment', 'BulkCreationParameters', - 'BulkCreationParametersFragment', 'CloudErrorBody', 'ComputeDataDisk', - 'ComputeDataDiskFragment', 'ComputeVmInstanceViewStatus', - 'ComputeVmInstanceViewStatusFragment', 'ComputeVmProperties', - 'ComputeVmPropertiesFragment', 'CostThresholdProperties', 'CustomImage', 'CustomImageFragment', 'CustomImageList', 'CustomImagePropertiesCustom', - 'CustomImagePropertiesCustomFragment', 'CustomImagePropertiesFromPlan', - 'CustomImagePropertiesFromPlanFragment', 'CustomImagePropertiesFromVm', - 'CustomImagePropertiesFromVmFragment', 'DataDiskProperties', - 'DataDiskPropertiesFragment', 'DataDiskStorageTypeInfo', - 'DataDiskStorageTypeInfoFragment', 'DayDetails', - 'DayDetailsFragment', 'DetachDataDiskProperties', 'DetachDiskProperties', 'Disk', @@ -425,36 +206,28 @@ 'DtlEnvironmentFragment', 'DtlEnvironmentList', 'EnvironmentDeploymentProperties', - 'EnvironmentDeploymentPropertiesFragment', 'EvaluatePoliciesProperties', 'EvaluatePoliciesRequest', 'EvaluatePoliciesResponse', 'Event', - 'EventFragment', 'ExportResourceUsageParameters', 'ExternalSubnet', - 'ExternalSubnetFragment', 'Formula', 'FormulaFragment', 'FormulaList', 'FormulaPropertiesFromVm', - 'FormulaPropertiesFromVmFragment', 'GalleryImage', 'GalleryImageList', 'GalleryImageReference', - 'GalleryImageReferenceFragment', 'GenerateArmTemplateRequest', 'GenerateUploadUriParameter', 'GenerateUploadUriResponse', 'HourDetails', - 'HourDetailsFragment', 'IdentityProperties', 'ImportLabVirtualMachineRequest', 'InboundNatRule', - 'InboundNatRuleFragment', 'Lab', 'LabAnnouncementProperties', - 'LabAnnouncementPropertiesFragment', 'LabCost', 'LabCostDetailsProperties', 'LabCostSummaryProperties', @@ -462,23 +235,18 @@ 'LabList', 'LabResourceCostProperties', 'LabSupportProperties', - 'LabSupportPropertiesFragment', 'LabVhd', 'LabVhdList', 'LabVirtualMachine', 'LabVirtualMachineCreationParameter', - 'LabVirtualMachineCreationParameterFragment', 'LabVirtualMachineFragment', 'LabVirtualMachineList', 'LinuxOsInfo', - 'LinuxOsInfoFragment', 'NetworkInterfaceProperties', - 'NetworkInterfacePropertiesFragment', 'NotificationChannel', 'NotificationChannelFragment', 'NotificationChannelList', 'NotificationSettings', - 'NotificationSettingsFragment', 'NotifyParameters', 'OperationError', 'OperationMetadata', @@ -493,7 +261,6 @@ 'PolicySetResult', 'PolicyViolation', 'Port', - 'PortFragment', 'ProviderOperationResult', 'RdpConnection', 'ResizeLabVirtualMachineProperties', @@ -501,7 +268,6 @@ 'RetargetScheduleProperties', 'Schedule', 'ScheduleCreationParameter', - 'ScheduleCreationParameterFragment', 'ScheduleFragment', 'ScheduleList', 'Secret', @@ -511,31 +277,24 @@ 'ServiceFabricFragment', 'ServiceFabricList', 'ServiceRunner', + 'ServiceRunnerList', 'SharedPublicIpAddressConfiguration', - 'SharedPublicIpAddressConfigurationFragment', 'ShutdownNotificationContent', 'Subnet', - 'SubnetFragment', 'SubnetOverride', - 'SubnetOverrideFragment', 'SubnetSharedPublicIpAddressConfiguration', - 'SubnetSharedPublicIpAddressConfigurationFragment', 'TargetCostProperties', 'UpdateResource', 'User', 'UserFragment', 'UserIdentity', - 'UserIdentityFragment', 'UserList', 'UserSecretStore', - 'UserSecretStoreFragment', 'VirtualNetwork', 'VirtualNetworkFragment', 'VirtualNetworkList', 'WeekDetails', - 'WeekDetailsFragment', 'WindowsOsInfo', - 'WindowsOsInfoFragment', 'CostThresholdStatus', 'CostType', 'CustomImageOsType', @@ -545,6 +304,7 @@ 'HostCachingOptions', 'HttpStatusCode', 'LinuxOsState', + 'ManagedIdentityType', 'NotificationChannelEventType', 'PolicyEvaluatorType', 'PolicyFactName', diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_dev_test_labs_client_enums.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_dev_test_labs_client_enums.py index 177f446ee1c5..0e85c7d693c0 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_dev_test_labs_client_enums.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_dev_test_labs_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CostThresholdStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CostThresholdStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates whether this threshold will be displayed on cost charts. """ ENABLED = "Enabled" DISABLED = "Disabled" -class CostType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CostType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the cost. """ @@ -41,7 +26,7 @@ class CostType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REPORTED = "Reported" PROJECTED = "Projected" -class CustomImageOsType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CustomImageOsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The OS type of the custom image (i.e. Windows, Linux) """ @@ -49,21 +34,21 @@ class CustomImageOsType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LINUX = "Linux" NONE = "None" -class EnableStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """If notifications are enabled for this schedule (i.e. Enabled, Disabled). +class EnableStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Indicates if the artifact source is enabled (values: Enabled, Disabled). """ ENABLED = "Enabled" DISABLED = "Disabled" -class EnvironmentPermission(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EnvironmentPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The access rights to be granted to the user when provisioning an environment """ READER = "Reader" CONTRIBUTOR = "Contributor" -class FileUploadOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FileUploadOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Options for uploading the files for the artifact. UploadFilesAndGenerateSasTokens is the default value. """ @@ -71,7 +56,7 @@ class FileUploadOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPLOAD_FILES_AND_GENERATE_SAS_TOKENS = "UploadFilesAndGenerateSasTokens" NONE = "None" -class HostCachingOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HostCachingOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Caching option for a data disk (i.e. None, ReadOnly, ReadWrite). """ @@ -79,7 +64,7 @@ class HostCachingOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HttpStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status code for the operation. """ @@ -93,13 +78,18 @@ class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESET_CONTENT = "ResetContent" PARTIAL_CONTENT = "PartialContent" MULTIPLE_CHOICES = "MultipleChoices" + AMBIGUOUS = "Ambiguous" MOVED_PERMANENTLY = "MovedPermanently" + MOVED = "Moved" + FOUND = "Found" REDIRECT = "Redirect" SEE_OTHER = "SeeOther" + REDIRECT_METHOD = "RedirectMethod" NOT_MODIFIED = "NotModified" USE_PROXY = "UseProxy" UNUSED = "Unused" TEMPORARY_REDIRECT = "TemporaryRedirect" + REDIRECT_KEEP_VERB = "RedirectKeepVerb" BAD_REQUEST = "BadRequest" UNAUTHORIZED = "Unauthorized" PAYMENT_REQUIRED = "PaymentRequired" @@ -126,7 +116,7 @@ class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GATEWAY_TIMEOUT = "GatewayTimeout" HTTP_VERSION_NOT_SUPPORTED = "HttpVersionNotSupported" -class LinuxOsState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LinuxOsState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the Linux OS (i.e. NonDeprovisioned, DeprovisionRequested, DeprovisionApplied). """ @@ -134,21 +124,30 @@ class LinuxOsState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEPROVISION_REQUESTED = "DeprovisionRequested" DEPROVISION_APPLIED = "DeprovisionApplied" -class NotificationChannelEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Managed identity. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + +class NotificationChannelEventType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The event type for which this notification is enabled (i.e. AutoShutdown, Cost) """ AUTO_SHUTDOWN = "AutoShutdown" COST = "Cost" -class PolicyEvaluatorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyEvaluatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The evaluator type of the policy (i.e. AllowedValuesPolicy, MaxValuePolicy). """ ALLOWED_VALUES_POLICY = "AllowedValuesPolicy" MAX_VALUE_POLICY = "MaxValuePolicy" -class PolicyFactName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyFactName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The fact name of the policy (e.g. LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. """ @@ -163,14 +162,14 @@ class PolicyFactName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ENVIRONMENT_TEMPLATE = "EnvironmentTemplate" SCHEDULE_EDIT_PERMISSION = "ScheduleEditPermission" -class PolicyStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the policy. """ ENABLED = "Enabled" DISABLED = "Disabled" -class PremiumDataDisk(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PremiumDataDisk(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The setting to enable usage of premium data disks. When its value is 'Enabled', creation of standard or premium data disks is allowed. When its value is 'Disabled', only creation of standard data disks is allowed. @@ -179,21 +178,22 @@ class PremiumDataDisk(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" ENABLED = "Enabled" -class ReportingCycleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReportingCycleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Reporting cycle type. """ CALENDAR_MONTH = "CalendarMonth" CUSTOM = "Custom" -class SourceControlType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SourceControlType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The artifact source's type. """ VSO_GIT = "VsoGit" GIT_HUB = "GitHub" + STORAGE_ACCOUNT = "StorageAccount" -class StorageType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The storage type for the disk (i.e. Standard, Premium). """ @@ -201,21 +201,21 @@ class StorageType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PREMIUM = "Premium" STANDARD_SSD = "StandardSSD" -class TargetCostStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TargetCostStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Target cost status """ ENABLED = "Enabled" DISABLED = "Disabled" -class TransportProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TransportProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The transport protocol for the endpoint. """ TCP = "Tcp" UDP = "Udp" -class UsagePermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UsagePermissionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permission policy of the subnet for allowing public IP addresses (i.e. Allow, Deny)). """ @@ -223,7 +223,7 @@ class UsagePermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DENY = "Deny" ALLOW = "Allow" -class VirtualMachineCreationSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineCreationSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Tells source of creation of lab virtual machine. Output property only. """ @@ -231,7 +231,7 @@ class VirtualMachineCreationSource(with_metaclass(_CaseInsensitiveEnumMeta, str, FROM_GALLERY_IMAGE = "FromGalleryImage" FROM_SHARED_GALLERY_IMAGE = "FromSharedGalleryImage" -class WindowsOsState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WindowsOsState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of the Windows OS (i.e. NonSysprepped, SysprepRequested, SysprepApplied). """ diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_models.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_models.py deleted file mode 100644 index 41e15954b6bd..000000000000 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_models.py +++ /dev/null @@ -1,6270 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """An Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, 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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -class ApplicableSchedule(Resource): - """Schedules applicable to a virtual machine. The schedules may have been defined on a VM or on lab level. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param lab_vms_shutdown: The auto-shutdown schedule, if one has been set at the lab or lab - resource level. - :type lab_vms_shutdown: ~azure.mgmt.devtestlabs.models.Schedule - :param lab_vms_startup: The auto-startup schedule, if one has been set at the lab or lab - resource level. - :type lab_vms_startup: ~azure.mgmt.devtestlabs.models.Schedule - """ - - _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'lab_vms_shutdown': {'key': 'properties.labVmsShutdown', 'type': 'Schedule'}, - 'lab_vms_startup': {'key': 'properties.labVmsStartup', 'type': 'Schedule'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicableSchedule, self).__init__(**kwargs) - self.lab_vms_shutdown = kwargs.get('lab_vms_shutdown', None) - self.lab_vms_startup = kwargs.get('lab_vms_startup', None) - - -class UpdateResource(msrest.serialization.Model): - """Represents an update resource. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class ApplicableScheduleFragment(UpdateResource): - """Schedules applicable to a virtual machine. The schedules may have been defined on a VM or on lab level. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param lab_vms_shutdown: The auto-shutdown schedule, if one has been set at the lab or lab - resource level. - :type lab_vms_shutdown: ~azure.mgmt.devtestlabs.models.ScheduleFragment - :param lab_vms_startup: The auto-startup schedule, if one has been set at the lab or lab - resource level. - :type lab_vms_startup: ~azure.mgmt.devtestlabs.models.ScheduleFragment - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'lab_vms_shutdown': {'key': 'properties.labVmsShutdown', 'type': 'ScheduleFragment'}, - 'lab_vms_startup': {'key': 'properties.labVmsStartup', 'type': 'ScheduleFragment'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicableScheduleFragment, self).__init__(**kwargs) - self.lab_vms_shutdown = kwargs.get('lab_vms_shutdown', None) - self.lab_vms_startup = kwargs.get('lab_vms_startup', None) - - -class ApplyArtifactsRequest(msrest.serialization.Model): - """Request body for applying artifacts to a virtual machine. - - :param artifacts: The list of artifacts to apply. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] - """ - - _attribute_map = { - 'artifacts': {'key': 'artifacts', 'type': '[ArtifactInstallProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplyArtifactsRequest, self).__init__(**kwargs) - self.artifacts = kwargs.get('artifacts', None) - - -class ArmTemplate(Resource): - """An Azure Resource Manager template. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :ivar display_name: The display name of the ARM template. - :vartype display_name: str - :ivar description: The description of the ARM template. - :vartype description: str - :ivar publisher: The publisher of the ARM template. - :vartype publisher: str - :ivar icon: The URI to the icon of the ARM template. - :vartype icon: str - :ivar contents: The contents of the ARM template. - :vartype contents: object - :ivar created_date: The creation date of the armTemplate. - :vartype created_date: ~datetime.datetime - :ivar parameters_value_files_info: File name and parameter values information from all - azuredeploy.*.parameters.json for the ARM template. - :vartype parameters_value_files_info: - list[~azure.mgmt.devtestlabs.models.ParametersValueFileInfo] - :ivar enabled: Whether or not ARM template is enabled for use by lab user. - :vartype enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'description': {'readonly': True}, - 'publisher': {'readonly': True}, - 'icon': {'readonly': True}, - 'contents': {'readonly': True}, - 'created_date': {'readonly': True}, - 'parameters_value_files_info': {'readonly': True}, - 'enabled': {'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}'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'publisher': {'key': 'properties.publisher', 'type': 'str'}, - 'icon': {'key': 'properties.icon', 'type': 'str'}, - 'contents': {'key': 'properties.contents', 'type': 'object'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'parameters_value_files_info': {'key': 'properties.parametersValueFilesInfo', 'type': '[ParametersValueFileInfo]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmTemplate, self).__init__(**kwargs) - self.display_name = None - self.description = None - self.publisher = None - self.icon = None - self.contents = None - self.created_date = None - self.parameters_value_files_info = None - self.enabled = None - - -class ArmTemplateInfo(msrest.serialization.Model): - """Information about a generated ARM template. - - :param template: The template's contents. - :type template: object - :param parameters: The parameters of the ARM template. - :type parameters: object - """ - - _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmTemplateInfo, self).__init__(**kwargs) - self.template = kwargs.get('template', None) - self.parameters = kwargs.get('parameters', None) - - -class ArmTemplateList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.ArmTemplate] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmTemplate]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmTemplateList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ArmTemplateParameterProperties(msrest.serialization.Model): - """Properties of an Azure Resource Manager template parameter. - - :param name: The name of the template parameter. - :type name: str - :param value: The value of the template parameter. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmTemplateParameterProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class ArmTemplateParameterPropertiesFragment(msrest.serialization.Model): - """Properties of an Azure Resource Manager template parameter. - - :param name: The name of the template parameter. - :type name: str - :param value: The value of the template parameter. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmTemplateParameterPropertiesFragment, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class Artifact(Resource): - """An artifact. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :ivar title: The artifact's title. - :vartype title: str - :ivar description: The artifact's description. - :vartype description: str - :ivar publisher: The artifact's publisher. - :vartype publisher: str - :ivar file_path: The file path to the artifact. - :vartype file_path: str - :ivar icon: The URI to the artifact icon. - :vartype icon: str - :ivar target_os_type: The artifact's target OS. - :vartype target_os_type: str - :ivar parameters: The artifact's parameters. - :vartype parameters: object - :ivar created_date: The artifact's creation date. - :vartype created_date: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'description': {'readonly': True}, - 'publisher': {'readonly': True}, - 'file_path': {'readonly': True}, - 'icon': {'readonly': True}, - 'target_os_type': {'readonly': True}, - 'parameters': {'readonly': True}, - 'created_date': {'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}'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'publisher': {'key': 'properties.publisher', 'type': 'str'}, - 'file_path': {'key': 'properties.filePath', 'type': 'str'}, - 'icon': {'key': 'properties.icon', 'type': 'str'}, - 'target_os_type': {'key': 'properties.targetOsType', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Artifact, self).__init__(**kwargs) - self.title = None - self.description = None - self.publisher = None - self.file_path = None - self.icon = None - self.target_os_type = None - self.parameters = None - self.created_date = None - - -class ArtifactDeploymentStatusProperties(msrest.serialization.Model): - """Properties of an artifact deployment. - - :param deployment_status: The deployment status of the artifact. - :type deployment_status: str - :param artifacts_applied: The total count of the artifacts that were successfully applied. - :type artifacts_applied: int - :param total_artifacts: The total count of the artifacts that were tentatively applied. - :type total_artifacts: int - """ - - _attribute_map = { - 'deployment_status': {'key': 'deploymentStatus', 'type': 'str'}, - 'artifacts_applied': {'key': 'artifactsApplied', 'type': 'int'}, - 'total_artifacts': {'key': 'totalArtifacts', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactDeploymentStatusProperties, self).__init__(**kwargs) - self.deployment_status = kwargs.get('deployment_status', None) - self.artifacts_applied = kwargs.get('artifacts_applied', None) - self.total_artifacts = kwargs.get('total_artifacts', None) - - -class ArtifactDeploymentStatusPropertiesFragment(msrest.serialization.Model): - """Properties of an artifact deployment. - - :param deployment_status: The deployment status of the artifact. - :type deployment_status: str - :param artifacts_applied: The total count of the artifacts that were successfully applied. - :type artifacts_applied: int - :param total_artifacts: The total count of the artifacts that were tentatively applied. - :type total_artifacts: int - """ - - _attribute_map = { - 'deployment_status': {'key': 'deploymentStatus', 'type': 'str'}, - 'artifacts_applied': {'key': 'artifactsApplied', 'type': 'int'}, - 'total_artifacts': {'key': 'totalArtifacts', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactDeploymentStatusPropertiesFragment, self).__init__(**kwargs) - self.deployment_status = kwargs.get('deployment_status', None) - self.artifacts_applied = kwargs.get('artifacts_applied', None) - self.total_artifacts = kwargs.get('total_artifacts', None) - - -class ArtifactInstallProperties(msrest.serialization.Model): - """Properties of an artifact. - - :param artifact_id: The artifact's identifier. - :type artifact_id: str - :param artifact_title: The artifact's title. - :type artifact_title: str - :param parameters: The parameters of the artifact. - :type parameters: list[~azure.mgmt.devtestlabs.models.ArtifactParameterProperties] - :param status: The status of the artifact. - :type status: str - :param deployment_status_message: The status message from the deployment. - :type deployment_status_message: str - :param vm_extension_status_message: The status message from the virtual machine extension. - :type vm_extension_status_message: str - :param install_time: The time that the artifact starts to install on the virtual machine. - :type install_time: ~datetime.datetime - """ - - _attribute_map = { - 'artifact_id': {'key': 'artifactId', 'type': 'str'}, - 'artifact_title': {'key': 'artifactTitle', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ArtifactParameterProperties]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'deployment_status_message': {'key': 'deploymentStatusMessage', 'type': 'str'}, - 'vm_extension_status_message': {'key': 'vmExtensionStatusMessage', 'type': 'str'}, - 'install_time': {'key': 'installTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactInstallProperties, self).__init__(**kwargs) - self.artifact_id = kwargs.get('artifact_id', None) - self.artifact_title = kwargs.get('artifact_title', None) - self.parameters = kwargs.get('parameters', None) - self.status = kwargs.get('status', None) - self.deployment_status_message = kwargs.get('deployment_status_message', None) - self.vm_extension_status_message = kwargs.get('vm_extension_status_message', None) - self.install_time = kwargs.get('install_time', None) - - -class ArtifactInstallPropertiesFragment(msrest.serialization.Model): - """Properties of an artifact. - - :param artifact_id: The artifact's identifier. - :type artifact_id: str - :param artifact_title: The artifact's title. - :type artifact_title: str - :param parameters: The parameters of the artifact. - :type parameters: list[~azure.mgmt.devtestlabs.models.ArtifactParameterPropertiesFragment] - :param status: The status of the artifact. - :type status: str - :param deployment_status_message: The status message from the deployment. - :type deployment_status_message: str - :param vm_extension_status_message: The status message from the virtual machine extension. - :type vm_extension_status_message: str - :param install_time: The time that the artifact starts to install on the virtual machine. - :type install_time: ~datetime.datetime - """ - - _attribute_map = { - 'artifact_id': {'key': 'artifactId', 'type': 'str'}, - 'artifact_title': {'key': 'artifactTitle', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ArtifactParameterPropertiesFragment]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'deployment_status_message': {'key': 'deploymentStatusMessage', 'type': 'str'}, - 'vm_extension_status_message': {'key': 'vmExtensionStatusMessage', 'type': 'str'}, - 'install_time': {'key': 'installTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactInstallPropertiesFragment, self).__init__(**kwargs) - self.artifact_id = kwargs.get('artifact_id', None) - self.artifact_title = kwargs.get('artifact_title', None) - self.parameters = kwargs.get('parameters', None) - self.status = kwargs.get('status', None) - self.deployment_status_message = kwargs.get('deployment_status_message', None) - self.vm_extension_status_message = kwargs.get('vm_extension_status_message', None) - self.install_time = kwargs.get('install_time', None) - - -class ArtifactList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Artifact] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Artifact]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ArtifactParameterProperties(msrest.serialization.Model): - """Properties of an artifact parameter. - - :param name: The name of the artifact parameter. - :type name: str - :param value: The value of the artifact parameter. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactParameterProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class ArtifactParameterPropertiesFragment(msrest.serialization.Model): - """Properties of an artifact parameter. - - :param name: The name of the artifact parameter. - :type name: str - :param value: The value of the artifact parameter. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactParameterPropertiesFragment, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class ArtifactSource(Resource): - """Properties of an artifact source. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param display_name: The artifact source's display name. - :type display_name: str - :param uri: The artifact source's URI. - :type uri: str - :param source_type: The artifact source's type. Possible values include: "VsoGit", "GitHub". - :type source_type: str or ~azure.mgmt.devtestlabs.models.SourceControlType - :param folder_path: The folder containing artifacts. - :type folder_path: str - :param arm_template_folder_path: The folder containing Azure Resource Manager templates. - :type arm_template_folder_path: str - :param branch_ref: The artifact source's branch reference. - :type branch_ref: str - :param security_token: The security token to authenticate to the artifact source. - :type security_token: str - :param status: Indicates if the artifact source is enabled (values: Enabled, Disabled). - Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :ivar created_date: The artifact source's creation date. - :vartype created_date: ~datetime.datetime - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'source_type': {'key': 'properties.sourceType', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'arm_template_folder_path': {'key': 'properties.armTemplateFolderPath', 'type': 'str'}, - 'branch_ref': {'key': 'properties.branchRef', 'type': 'str'}, - 'security_token': {'key': 'properties.securityToken', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactSource, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.uri = kwargs.get('uri', None) - self.source_type = kwargs.get('source_type', None) - self.folder_path = kwargs.get('folder_path', None) - self.arm_template_folder_path = kwargs.get('arm_template_folder_path', None) - self.branch_ref = kwargs.get('branch_ref', None) - self.security_token = kwargs.get('security_token', None) - self.status = kwargs.get('status', None) - self.created_date = None - self.provisioning_state = None - self.unique_identifier = None - - -class ArtifactSourceFragment(UpdateResource): - """Properties of an artifact source. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param display_name: The artifact source's display name. - :type display_name: str - :param uri: The artifact source's URI. - :type uri: str - :param source_type: The artifact source's type. Possible values include: "VsoGit", "GitHub". - :type source_type: str or ~azure.mgmt.devtestlabs.models.SourceControlType - :param folder_path: The folder containing artifacts. - :type folder_path: str - :param arm_template_folder_path: The folder containing Azure Resource Manager templates. - :type arm_template_folder_path: str - :param branch_ref: The artifact source's branch reference. - :type branch_ref: str - :param security_token: The security token to authenticate to the artifact source. - :type security_token: str - :param status: Indicates if the artifact source is enabled (values: Enabled, Disabled). - Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'source_type': {'key': 'properties.sourceType', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'arm_template_folder_path': {'key': 'properties.armTemplateFolderPath', 'type': 'str'}, - 'branch_ref': {'key': 'properties.branchRef', 'type': 'str'}, - 'security_token': {'key': 'properties.securityToken', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactSourceFragment, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.uri = kwargs.get('uri', None) - self.source_type = kwargs.get('source_type', None) - self.folder_path = kwargs.get('folder_path', None) - self.arm_template_folder_path = kwargs.get('arm_template_folder_path', None) - self.branch_ref = kwargs.get('branch_ref', None) - self.security_token = kwargs.get('security_token', None) - self.status = kwargs.get('status', None) - - -class ArtifactSourceList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.ArtifactSource] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ArtifactSource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactSourceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AttachDiskProperties(msrest.serialization.Model): - """Properties of the disk to attach. - - :param leased_by_lab_vm_id: The resource ID of the Lab virtual machine to which the disk is - attached. - :type leased_by_lab_vm_id: str - """ - - _attribute_map = { - 'leased_by_lab_vm_id': {'key': 'leasedByLabVmId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AttachDiskProperties, self).__init__(**kwargs) - self.leased_by_lab_vm_id = kwargs.get('leased_by_lab_vm_id', None) - - -class AttachNewDataDiskOptions(msrest.serialization.Model): - """Properties to attach new disk to the Virtual Machine. - - :param disk_size_gi_b: Size of the disk to be attached in GibiBytes. - :type disk_size_gi_b: int - :param disk_name: The name of the disk to be attached. - :type disk_name: str - :param disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values - include: "Standard", "Premium", "StandardSSD". - :type disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType - """ - - _attribute_map = { - 'disk_size_gi_b': {'key': 'diskSizeGiB', 'type': 'int'}, - 'disk_name': {'key': 'diskName', 'type': 'str'}, - 'disk_type': {'key': 'diskType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AttachNewDataDiskOptions, self).__init__(**kwargs) - self.disk_size_gi_b = kwargs.get('disk_size_gi_b', None) - self.disk_name = kwargs.get('disk_name', None) - self.disk_type = kwargs.get('disk_type', None) - - -class AttachNewDataDiskOptionsFragment(msrest.serialization.Model): - """Properties to attach new disk to the Virtual Machine. - - :param disk_size_gi_b: Size of the disk to be attached in GibiBytes. - :type disk_size_gi_b: int - :param disk_name: The name of the disk to be attached. - :type disk_name: str - :param disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values - include: "Standard", "Premium", "StandardSSD". - :type disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType - """ - - _attribute_map = { - 'disk_size_gi_b': {'key': 'diskSizeGiB', 'type': 'int'}, - 'disk_name': {'key': 'diskName', 'type': 'str'}, - 'disk_type': {'key': 'diskType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AttachNewDataDiskOptionsFragment, self).__init__(**kwargs) - self.disk_size_gi_b = kwargs.get('disk_size_gi_b', None) - self.disk_name = kwargs.get('disk_name', None) - self.disk_type = kwargs.get('disk_type', None) - - -class BulkCreationParameters(msrest.serialization.Model): - """Parameters for creating multiple virtual machines as a single action. - - :param instance_count: The number of virtual machine instances to create. - :type instance_count: int - """ - - _attribute_map = { - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(BulkCreationParameters, self).__init__(**kwargs) - self.instance_count = kwargs.get('instance_count', None) - - -class BulkCreationParametersFragment(msrest.serialization.Model): - """Parameters for creating multiple virtual machines as a single action. - - :param instance_count: The number of virtual machine instances to create. - :type instance_count: int - """ - - _attribute_map = { - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(BulkCreationParametersFragment, self).__init__(**kwargs) - self.instance_count = kwargs.get('instance_count', None) - - -class CloudErrorBody(msrest.serialization.Model): - """Body of an error from a REST request. - - :param code: The error code. - :type code: str - :param message: The error message. - :type message: str - :param target: The error target. - :type target: str - :param details: Inner errors. - :type details: list[~azure.mgmt.devtestlabs.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class ComputeDataDisk(msrest.serialization.Model): - """A data disks attached to a virtual machine. - - :param name: Gets data disk name. - :type name: str - :param disk_uri: When backed by a blob, the URI of underlying blob. - :type disk_uri: str - :param managed_disk_id: When backed by managed disk, this is the ID of the compute disk - resource. - :type managed_disk_id: str - :param disk_size_gi_b: Gets data disk size in GiB. - :type disk_size_gi_b: int - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'disk_uri': {'key': 'diskUri', 'type': 'str'}, - 'managed_disk_id': {'key': 'managedDiskId', 'type': 'str'}, - 'disk_size_gi_b': {'key': 'diskSizeGiB', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeDataDisk, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.disk_uri = kwargs.get('disk_uri', None) - self.managed_disk_id = kwargs.get('managed_disk_id', None) - self.disk_size_gi_b = kwargs.get('disk_size_gi_b', None) - - -class ComputeDataDiskFragment(msrest.serialization.Model): - """A data disks attached to a virtual machine. - - :param name: Gets data disk name. - :type name: str - :param disk_uri: When backed by a blob, the URI of underlying blob. - :type disk_uri: str - :param managed_disk_id: When backed by managed disk, this is the ID of the compute disk - resource. - :type managed_disk_id: str - :param disk_size_gi_b: Gets data disk size in GiB. - :type disk_size_gi_b: int - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'disk_uri': {'key': 'diskUri', 'type': 'str'}, - 'managed_disk_id': {'key': 'managedDiskId', 'type': 'str'}, - 'disk_size_gi_b': {'key': 'diskSizeGiB', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeDataDiskFragment, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.disk_uri = kwargs.get('disk_uri', None) - self.managed_disk_id = kwargs.get('managed_disk_id', None) - self.disk_size_gi_b = kwargs.get('disk_size_gi_b', None) - - -class ComputeVmInstanceViewStatus(msrest.serialization.Model): - """Status information about a virtual machine. - - :param code: Gets the status Code. - :type code: str - :param display_status: Gets the short localizable label for the status. - :type display_status: str - :param message: Gets the message associated with the status. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeVmInstanceViewStatus, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.display_status = kwargs.get('display_status', None) - self.message = kwargs.get('message', None) - - -class ComputeVmInstanceViewStatusFragment(msrest.serialization.Model): - """Status information about a virtual machine. - - :param code: Gets the status Code. - :type code: str - :param display_status: Gets the short localizable label for the status. - :type display_status: str - :param message: Gets the message associated with the status. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeVmInstanceViewStatusFragment, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.display_status = kwargs.get('display_status', None) - self.message = kwargs.get('message', None) - - -class ComputeVmProperties(msrest.serialization.Model): - """Properties of a virtual machine returned by the Microsoft.Compute API. - - :param statuses: Gets the statuses of the virtual machine. - :type statuses: list[~azure.mgmt.devtestlabs.models.ComputeVmInstanceViewStatus] - :param os_type: Gets the OS type of the virtual machine. - :type os_type: str - :param vm_size: Gets the size of the virtual machine. - :type vm_size: str - :param network_interface_id: Gets the network interface ID of the virtual machine. - :type network_interface_id: str - :param os_disk_id: Gets OS disk blob uri for the virtual machine. - :type os_disk_id: str - :param data_disk_ids: Gets data disks blob uri for the virtual machine. - :type data_disk_ids: list[str] - :param data_disks: Gets all data disks attached to the virtual machine. - :type data_disks: list[~azure.mgmt.devtestlabs.models.ComputeDataDisk] - """ - - _attribute_map = { - 'statuses': {'key': 'statuses', 'type': '[ComputeVmInstanceViewStatus]'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'network_interface_id': {'key': 'networkInterfaceId', 'type': 'str'}, - 'os_disk_id': {'key': 'osDiskId', 'type': 'str'}, - 'data_disk_ids': {'key': 'dataDiskIds', 'type': '[str]'}, - 'data_disks': {'key': 'dataDisks', 'type': '[ComputeDataDisk]'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeVmProperties, self).__init__(**kwargs) - self.statuses = kwargs.get('statuses', None) - self.os_type = kwargs.get('os_type', None) - self.vm_size = kwargs.get('vm_size', None) - self.network_interface_id = kwargs.get('network_interface_id', None) - self.os_disk_id = kwargs.get('os_disk_id', None) - self.data_disk_ids = kwargs.get('data_disk_ids', None) - self.data_disks = kwargs.get('data_disks', None) - - -class ComputeVmPropertiesFragment(msrest.serialization.Model): - """Properties of a virtual machine returned by the Microsoft.Compute API. - - :param statuses: Gets the statuses of the virtual machine. - :type statuses: list[~azure.mgmt.devtestlabs.models.ComputeVmInstanceViewStatusFragment] - :param os_type: Gets the OS type of the virtual machine. - :type os_type: str - :param vm_size: Gets the size of the virtual machine. - :type vm_size: str - :param network_interface_id: Gets the network interface ID of the virtual machine. - :type network_interface_id: str - :param os_disk_id: Gets OS disk blob uri for the virtual machine. - :type os_disk_id: str - :param data_disk_ids: Gets data disks blob uri for the virtual machine. - :type data_disk_ids: list[str] - :param data_disks: Gets all data disks attached to the virtual machine. - :type data_disks: list[~azure.mgmt.devtestlabs.models.ComputeDataDiskFragment] - """ - - _attribute_map = { - 'statuses': {'key': 'statuses', 'type': '[ComputeVmInstanceViewStatusFragment]'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'network_interface_id': {'key': 'networkInterfaceId', 'type': 'str'}, - 'os_disk_id': {'key': 'osDiskId', 'type': 'str'}, - 'data_disk_ids': {'key': 'dataDiskIds', 'type': '[str]'}, - 'data_disks': {'key': 'dataDisks', 'type': '[ComputeDataDiskFragment]'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeVmPropertiesFragment, self).__init__(**kwargs) - self.statuses = kwargs.get('statuses', None) - self.os_type = kwargs.get('os_type', None) - self.vm_size = kwargs.get('vm_size', None) - self.network_interface_id = kwargs.get('network_interface_id', None) - self.os_disk_id = kwargs.get('os_disk_id', None) - self.data_disk_ids = kwargs.get('data_disk_ids', None) - self.data_disks = kwargs.get('data_disks', None) - - -class CostThresholdProperties(msrest.serialization.Model): - """Properties of a cost threshold item. - - :param threshold_id: The ID of the cost threshold item. - :type threshold_id: str - :param percentage_threshold: The value of the percentage cost threshold. - :type percentage_threshold: ~azure.mgmt.devtestlabs.models.PercentageCostThresholdProperties - :param display_on_chart: Indicates whether this threshold will be displayed on cost charts. - Possible values include: "Enabled", "Disabled". - :type display_on_chart: str or ~azure.mgmt.devtestlabs.models.CostThresholdStatus - :param send_notification_when_exceeded: Indicates whether notifications will be sent when this - threshold is exceeded. Possible values include: "Enabled", "Disabled". - :type send_notification_when_exceeded: str or - ~azure.mgmt.devtestlabs.models.CostThresholdStatus - :param notification_sent: Indicates the datetime when notifications were last sent for this - threshold. - :type notification_sent: str - """ - - _attribute_map = { - 'threshold_id': {'key': 'thresholdId', 'type': 'str'}, - 'percentage_threshold': {'key': 'percentageThreshold', 'type': 'PercentageCostThresholdProperties'}, - 'display_on_chart': {'key': 'displayOnChart', 'type': 'str'}, - 'send_notification_when_exceeded': {'key': 'sendNotificationWhenExceeded', 'type': 'str'}, - 'notification_sent': {'key': 'notificationSent', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CostThresholdProperties, self).__init__(**kwargs) - self.threshold_id = kwargs.get('threshold_id', None) - self.percentage_threshold = kwargs.get('percentage_threshold', None) - self.display_on_chart = kwargs.get('display_on_chart', None) - self.send_notification_when_exceeded = kwargs.get('send_notification_when_exceeded', None) - self.notification_sent = kwargs.get('notification_sent', None) - - -class CustomImage(Resource): - """A custom image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param vm: The virtual machine from which the image is to be created. - :type vm: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromVm - :param vhd: The VHD from which the image is to be created. - :type vhd: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesCustom - :param description: The description of the custom image. - :type description: str - :param author: The author of the custom image. - :type author: str - :ivar creation_date: The creation date of the custom image. - :vartype creation_date: ~datetime.datetime - :param managed_image_id: The Managed Image Id backing the custom image. - :type managed_image_id: str - :param managed_snapshot_id: The Managed Snapshot Id backing the custom image. - :type managed_snapshot_id: str - :param data_disk_storage_info: Storage information about the data disks present in the custom - image. - :type data_disk_storage_info: list[~azure.mgmt.devtestlabs.models.DataDiskStorageTypeInfo] - :param custom_image_plan: Storage information about the plan related to this custom image. - :type custom_image_plan: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromPlan - :param is_plan_authorized: Whether or not the custom images underlying offer/plan has been - enabled for programmatic deployment. - :type is_plan_authorized: bool - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'vm': {'key': 'properties.vm', 'type': 'CustomImagePropertiesFromVm'}, - 'vhd': {'key': 'properties.vhd', 'type': 'CustomImagePropertiesCustom'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'managed_image_id': {'key': 'properties.managedImageId', 'type': 'str'}, - 'managed_snapshot_id': {'key': 'properties.managedSnapshotId', 'type': 'str'}, - 'data_disk_storage_info': {'key': 'properties.dataDiskStorageInfo', 'type': '[DataDiskStorageTypeInfo]'}, - 'custom_image_plan': {'key': 'properties.customImagePlan', 'type': 'CustomImagePropertiesFromPlan'}, - 'is_plan_authorized': {'key': 'properties.isPlanAuthorized', 'type': 'bool'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImage, self).__init__(**kwargs) - self.vm = kwargs.get('vm', None) - self.vhd = kwargs.get('vhd', None) - self.description = kwargs.get('description', None) - self.author = kwargs.get('author', None) - self.creation_date = None - self.managed_image_id = kwargs.get('managed_image_id', None) - self.managed_snapshot_id = kwargs.get('managed_snapshot_id', None) - self.data_disk_storage_info = kwargs.get('data_disk_storage_info', None) - self.custom_image_plan = kwargs.get('custom_image_plan', None) - self.is_plan_authorized = kwargs.get('is_plan_authorized', None) - self.provisioning_state = None - self.unique_identifier = None - - -class CustomImageFragment(UpdateResource): - """A custom image. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param vm: The virtual machine from which the image is to be created. - :type vm: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromVmFragment - :param vhd: The VHD from which the image is to be created. - :type vhd: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesCustomFragment - :param description: The description of the custom image. - :type description: str - :param author: The author of the custom image. - :type author: str - :param managed_image_id: The Managed Image Id backing the custom image. - :type managed_image_id: str - :param managed_snapshot_id: The Managed Snapshot Id backing the custom image. - :type managed_snapshot_id: str - :param data_disk_storage_info: Storage information about the data disks present in the custom - image. - :type data_disk_storage_info: - list[~azure.mgmt.devtestlabs.models.DataDiskStorageTypeInfoFragment] - :param custom_image_plan: Storage information about the plan related to this custom image. - :type custom_image_plan: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromPlanFragment - :param is_plan_authorized: Whether or not the custom images underlying offer/plan has been - enabled for programmatic deployment. - :type is_plan_authorized: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'vm': {'key': 'properties.vm', 'type': 'CustomImagePropertiesFromVmFragment'}, - 'vhd': {'key': 'properties.vhd', 'type': 'CustomImagePropertiesCustomFragment'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'managed_image_id': {'key': 'properties.managedImageId', 'type': 'str'}, - 'managed_snapshot_id': {'key': 'properties.managedSnapshotId', 'type': 'str'}, - 'data_disk_storage_info': {'key': 'properties.dataDiskStorageInfo', 'type': '[DataDiskStorageTypeInfoFragment]'}, - 'custom_image_plan': {'key': 'properties.customImagePlan', 'type': 'CustomImagePropertiesFromPlanFragment'}, - 'is_plan_authorized': {'key': 'properties.isPlanAuthorized', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImageFragment, self).__init__(**kwargs) - self.vm = kwargs.get('vm', None) - self.vhd = kwargs.get('vhd', None) - self.description = kwargs.get('description', None) - self.author = kwargs.get('author', None) - self.managed_image_id = kwargs.get('managed_image_id', None) - self.managed_snapshot_id = kwargs.get('managed_snapshot_id', None) - self.data_disk_storage_info = kwargs.get('data_disk_storage_info', None) - self.custom_image_plan = kwargs.get('custom_image_plan', None) - self.is_plan_authorized = kwargs.get('is_plan_authorized', None) - - -class CustomImageList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.CustomImage] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomImage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImageList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class CustomImagePropertiesCustom(msrest.serialization.Model): - """Properties for creating a custom image from a VHD. - - All required parameters must be populated in order to send to Azure. - - :param image_name: The image name. - :type image_name: str - :param sys_prep: Indicates whether sysprep has been run on the VHD. - :type sys_prep: bool - :param os_type: Required. The OS type of the custom image (i.e. Windows, Linux). Possible - values include: "Windows", "Linux", "None". - :type os_type: str or ~azure.mgmt.devtestlabs.models.CustomImageOsType - """ - - _validation = { - 'os_type': {'required': True}, - } - - _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'sys_prep': {'key': 'sysPrep', 'type': 'bool'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImagePropertiesCustom, self).__init__(**kwargs) - self.image_name = kwargs.get('image_name', None) - self.sys_prep = kwargs.get('sys_prep', None) - self.os_type = kwargs['os_type'] - - -class CustomImagePropertiesCustomFragment(msrest.serialization.Model): - """Properties for creating a custom image from a VHD. - - :param image_name: The image name. - :type image_name: str - :param sys_prep: Indicates whether sysprep has been run on the VHD. - :type sys_prep: bool - :param os_type: The OS type of the custom image (i.e. Windows, Linux). Possible values include: - "Windows", "Linux", "None". - :type os_type: str or ~azure.mgmt.devtestlabs.models.CustomImageOsType - """ - - _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'sys_prep': {'key': 'sysPrep', 'type': 'bool'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImagePropertiesCustomFragment, self).__init__(**kwargs) - self.image_name = kwargs.get('image_name', None) - self.sys_prep = kwargs.get('sys_prep', None) - self.os_type = kwargs.get('os_type', None) - - -class CustomImagePropertiesFromPlan(msrest.serialization.Model): - """Properties for plan on a custom image. - - :param id: The id of the plan, equivalent to name of the plan. - :type id: str - :param publisher: The publisher for the plan from the marketplace image the custom image is - derived from. - :type publisher: str - :param offer: The offer for the plan from the marketplace image the custom image is derived - from. - :type offer: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImagePropertiesFromPlan, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.publisher = kwargs.get('publisher', None) - self.offer = kwargs.get('offer', None) - - -class CustomImagePropertiesFromPlanFragment(msrest.serialization.Model): - """Properties for plan on a custom image. - - :param id: The id of the plan, equivalent to name of the plan. - :type id: str - :param publisher: The publisher for the plan from the marketplace image the custom image is - derived from. - :type publisher: str - :param offer: The offer for the plan from the marketplace image the custom image is derived - from. - :type offer: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImagePropertiesFromPlanFragment, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.publisher = kwargs.get('publisher', None) - self.offer = kwargs.get('offer', None) - - -class CustomImagePropertiesFromVm(msrest.serialization.Model): - """Properties for creating a custom image from a virtual machine. - - :param source_vm_id: The source vm identifier. - :type source_vm_id: str - :param windows_os_info: The Windows OS information of the VM. - :type windows_os_info: ~azure.mgmt.devtestlabs.models.WindowsOsInfo - :param linux_os_info: The Linux OS information of the VM. - :type linux_os_info: ~azure.mgmt.devtestlabs.models.LinuxOsInfo - """ - - _attribute_map = { - 'source_vm_id': {'key': 'sourceVmId', 'type': 'str'}, - 'windows_os_info': {'key': 'windowsOsInfo', 'type': 'WindowsOsInfo'}, - 'linux_os_info': {'key': 'linuxOsInfo', 'type': 'LinuxOsInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImagePropertiesFromVm, self).__init__(**kwargs) - self.source_vm_id = kwargs.get('source_vm_id', None) - self.windows_os_info = kwargs.get('windows_os_info', None) - self.linux_os_info = kwargs.get('linux_os_info', None) - - -class CustomImagePropertiesFromVmFragment(msrest.serialization.Model): - """Properties for creating a custom image from a virtual machine. - - :param source_vm_id: The source vm identifier. - :type source_vm_id: str - :param windows_os_info: The Windows OS information of the VM. - :type windows_os_info: ~azure.mgmt.devtestlabs.models.WindowsOsInfoFragment - :param linux_os_info: The Linux OS information of the VM. - :type linux_os_info: ~azure.mgmt.devtestlabs.models.LinuxOsInfoFragment - """ - - _attribute_map = { - 'source_vm_id': {'key': 'sourceVmId', 'type': 'str'}, - 'windows_os_info': {'key': 'windowsOsInfo', 'type': 'WindowsOsInfoFragment'}, - 'linux_os_info': {'key': 'linuxOsInfo', 'type': 'LinuxOsInfoFragment'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomImagePropertiesFromVmFragment, self).__init__(**kwargs) - self.source_vm_id = kwargs.get('source_vm_id', None) - self.windows_os_info = kwargs.get('windows_os_info', None) - self.linux_os_info = kwargs.get('linux_os_info', None) - - -class DataDiskProperties(msrest.serialization.Model): - """Request body for adding a new or existing data disk to a virtual machine. - - :param attach_new_data_disk_options: Specifies options to attach a new disk to the virtual - machine. - :type attach_new_data_disk_options: ~azure.mgmt.devtestlabs.models.AttachNewDataDiskOptions - :param existing_lab_disk_id: Specifies the existing lab disk id to attach to virtual machine. - :type existing_lab_disk_id: str - :param host_caching: Caching option for a data disk (i.e. None, ReadOnly, ReadWrite). Possible - values include: "None", "ReadOnly", "ReadWrite". - :type host_caching: str or ~azure.mgmt.devtestlabs.models.HostCachingOptions - """ - - _attribute_map = { - 'attach_new_data_disk_options': {'key': 'attachNewDataDiskOptions', 'type': 'AttachNewDataDiskOptions'}, - 'existing_lab_disk_id': {'key': 'existingLabDiskId', 'type': 'str'}, - 'host_caching': {'key': 'hostCaching', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataDiskProperties, self).__init__(**kwargs) - self.attach_new_data_disk_options = kwargs.get('attach_new_data_disk_options', None) - self.existing_lab_disk_id = kwargs.get('existing_lab_disk_id', None) - self.host_caching = kwargs.get('host_caching', None) - - -class DataDiskPropertiesFragment(msrest.serialization.Model): - """Request body for adding a new or existing data disk to a virtual machine. - - :param attach_new_data_disk_options: Specifies options to attach a new disk to the virtual - machine. - :type attach_new_data_disk_options: - ~azure.mgmt.devtestlabs.models.AttachNewDataDiskOptionsFragment - :param existing_lab_disk_id: Specifies the existing lab disk id to attach to virtual machine. - :type existing_lab_disk_id: str - :param host_caching: Caching option for a data disk (i.e. None, ReadOnly, ReadWrite). Possible - values include: "None", "ReadOnly", "ReadWrite". - :type host_caching: str or ~azure.mgmt.devtestlabs.models.HostCachingOptions - """ - - _attribute_map = { - 'attach_new_data_disk_options': {'key': 'attachNewDataDiskOptions', 'type': 'AttachNewDataDiskOptionsFragment'}, - 'existing_lab_disk_id': {'key': 'existingLabDiskId', 'type': 'str'}, - 'host_caching': {'key': 'hostCaching', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataDiskPropertiesFragment, self).__init__(**kwargs) - self.attach_new_data_disk_options = kwargs.get('attach_new_data_disk_options', None) - self.existing_lab_disk_id = kwargs.get('existing_lab_disk_id', None) - self.host_caching = kwargs.get('host_caching', None) - - -class DataDiskStorageTypeInfo(msrest.serialization.Model): - """Storage information about the data disks present in the custom image. - - :param lun: Disk Lun. - :type lun: str - :param storage_type: Disk Storage Type. Possible values include: "Standard", "Premium", - "StandardSSD". - :type storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType - """ - - _attribute_map = { - 'lun': {'key': 'lun', 'type': 'str'}, - 'storage_type': {'key': 'storageType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataDiskStorageTypeInfo, self).__init__(**kwargs) - self.lun = kwargs.get('lun', None) - self.storage_type = kwargs.get('storage_type', None) - - -class DataDiskStorageTypeInfoFragment(msrest.serialization.Model): - """Storage information about the data disks present in the custom image. - - :param lun: Disk Lun. - :type lun: str - :param storage_type: Disk Storage Type. Possible values include: "Standard", "Premium", - "StandardSSD". - :type storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType - """ - - _attribute_map = { - 'lun': {'key': 'lun', 'type': 'str'}, - 'storage_type': {'key': 'storageType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataDiskStorageTypeInfoFragment, self).__init__(**kwargs) - self.lun = kwargs.get('lun', None) - self.storage_type = kwargs.get('storage_type', None) - - -class DayDetails(msrest.serialization.Model): - """Properties of a daily schedule. - - :param time: The time of day the schedule will occur. - :type time: str - """ - - _attribute_map = { - 'time': {'key': 'time', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DayDetails, self).__init__(**kwargs) - self.time = kwargs.get('time', None) - - -class DayDetailsFragment(msrest.serialization.Model): - """Properties of a daily schedule. - - :param time: The time of day the schedule will occur. - :type time: str - """ - - _attribute_map = { - 'time': {'key': 'time', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DayDetailsFragment, self).__init__(**kwargs) - self.time = kwargs.get('time', None) - - -class DetachDataDiskProperties(msrest.serialization.Model): - """Request body for detaching data disk from a virtual machine. - - :param existing_lab_disk_id: Specifies the disk resource ID to detach from virtual machine. - :type existing_lab_disk_id: str - """ - - _attribute_map = { - 'existing_lab_disk_id': {'key': 'existingLabDiskId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DetachDataDiskProperties, self).__init__(**kwargs) - self.existing_lab_disk_id = kwargs.get('existing_lab_disk_id', None) - - -class DetachDiskProperties(msrest.serialization.Model): - """Properties of the disk to detach. - - :param leased_by_lab_vm_id: The resource ID of the Lab VM to which the disk is attached. - :type leased_by_lab_vm_id: str - """ - - _attribute_map = { - 'leased_by_lab_vm_id': {'key': 'leasedByLabVmId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DetachDiskProperties, self).__init__(**kwargs) - self.leased_by_lab_vm_id = kwargs.get('leased_by_lab_vm_id', None) - - -class Disk(Resource): - """A Disk. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values - include: "Standard", "Premium", "StandardSSD". - :type disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType - :param disk_size_gi_b: The size of the disk in GibiBytes. - :type disk_size_gi_b: int - :param leased_by_lab_vm_id: The resource ID of the VM to which this disk is leased. - :type leased_by_lab_vm_id: str - :param disk_blob_name: When backed by a blob, the name of the VHD blob without extension. - :type disk_blob_name: str - :param disk_uri: When backed by a blob, the URI of underlying blob. - :type disk_uri: str - :ivar created_date: The creation date of the disk. - :vartype created_date: ~datetime.datetime - :param host_caching: The host caching policy of the disk (i.e. None, ReadOnly, ReadWrite). - :type host_caching: str - :param managed_disk_id: When backed by managed disk, this is the ID of the compute disk - resource. - :type managed_disk_id: str - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'disk_type': {'key': 'properties.diskType', 'type': 'str'}, - 'disk_size_gi_b': {'key': 'properties.diskSizeGiB', 'type': 'int'}, - 'leased_by_lab_vm_id': {'key': 'properties.leasedByLabVmId', 'type': 'str'}, - 'disk_blob_name': {'key': 'properties.diskBlobName', 'type': 'str'}, - 'disk_uri': {'key': 'properties.diskUri', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'host_caching': {'key': 'properties.hostCaching', 'type': 'str'}, - 'managed_disk_id': {'key': 'properties.managedDiskId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Disk, self).__init__(**kwargs) - self.disk_type = kwargs.get('disk_type', None) - self.disk_size_gi_b = kwargs.get('disk_size_gi_b', None) - self.leased_by_lab_vm_id = kwargs.get('leased_by_lab_vm_id', None) - self.disk_blob_name = kwargs.get('disk_blob_name', None) - self.disk_uri = kwargs.get('disk_uri', None) - self.created_date = None - self.host_caching = kwargs.get('host_caching', None) - self.managed_disk_id = kwargs.get('managed_disk_id', None) - self.provisioning_state = None - self.unique_identifier = None - - -class DiskFragment(UpdateResource): - """A Disk. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values - include: "Standard", "Premium", "StandardSSD". - :type disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType - :param disk_size_gi_b: The size of the disk in GibiBytes. - :type disk_size_gi_b: int - :param leased_by_lab_vm_id: The resource ID of the VM to which this disk is leased. - :type leased_by_lab_vm_id: str - :param disk_blob_name: When backed by a blob, the name of the VHD blob without extension. - :type disk_blob_name: str - :param disk_uri: When backed by a blob, the URI of underlying blob. - :type disk_uri: str - :param host_caching: The host caching policy of the disk (i.e. None, ReadOnly, ReadWrite). - :type host_caching: str - :param managed_disk_id: When backed by managed disk, this is the ID of the compute disk - resource. - :type managed_disk_id: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'disk_type': {'key': 'properties.diskType', 'type': 'str'}, - 'disk_size_gi_b': {'key': 'properties.diskSizeGiB', 'type': 'int'}, - 'leased_by_lab_vm_id': {'key': 'properties.leasedByLabVmId', 'type': 'str'}, - 'disk_blob_name': {'key': 'properties.diskBlobName', 'type': 'str'}, - 'disk_uri': {'key': 'properties.diskUri', 'type': 'str'}, - 'host_caching': {'key': 'properties.hostCaching', 'type': 'str'}, - 'managed_disk_id': {'key': 'properties.managedDiskId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DiskFragment, self).__init__(**kwargs) - self.disk_type = kwargs.get('disk_type', None) - self.disk_size_gi_b = kwargs.get('disk_size_gi_b', None) - self.leased_by_lab_vm_id = kwargs.get('leased_by_lab_vm_id', None) - self.disk_blob_name = kwargs.get('disk_blob_name', None) - self.disk_uri = kwargs.get('disk_uri', None) - self.host_caching = kwargs.get('host_caching', None) - self.managed_disk_id = kwargs.get('managed_disk_id', None) - - -class DiskList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Disk] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Disk]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DiskList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class DtlEnvironment(Resource): - """An environment, which is essentially an ARM template deployment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param deployment_properties: The deployment properties of the environment. - :type deployment_properties: ~azure.mgmt.devtestlabs.models.EnvironmentDeploymentProperties - :param arm_template_display_name: The display name of the Azure Resource Manager template that - produced the environment. - :type arm_template_display_name: str - :ivar resource_group_id: The identifier of the resource group containing the environment's - resources. - :vartype resource_group_id: str - :ivar created_by_user: The creator of the environment. - :vartype created_by_user: str - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_group_id': {'readonly': True}, - 'created_by_user': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'deployment_properties': {'key': 'properties.deploymentProperties', 'type': 'EnvironmentDeploymentProperties'}, - 'arm_template_display_name': {'key': 'properties.armTemplateDisplayName', 'type': 'str'}, - 'resource_group_id': {'key': 'properties.resourceGroupId', 'type': 'str'}, - 'created_by_user': {'key': 'properties.createdByUser', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DtlEnvironment, self).__init__(**kwargs) - self.deployment_properties = kwargs.get('deployment_properties', None) - self.arm_template_display_name = kwargs.get('arm_template_display_name', None) - self.resource_group_id = None - self.created_by_user = None - self.provisioning_state = None - self.unique_identifier = None - - -class DtlEnvironmentFragment(UpdateResource): - """An environment, which is essentially an ARM template deployment. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param deployment_properties: The deployment properties of the environment. - :type deployment_properties: - ~azure.mgmt.devtestlabs.models.EnvironmentDeploymentPropertiesFragment - :param arm_template_display_name: The display name of the Azure Resource Manager template that - produced the environment. - :type arm_template_display_name: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'deployment_properties': {'key': 'properties.deploymentProperties', 'type': 'EnvironmentDeploymentPropertiesFragment'}, - 'arm_template_display_name': {'key': 'properties.armTemplateDisplayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DtlEnvironmentFragment, self).__init__(**kwargs) - self.deployment_properties = kwargs.get('deployment_properties', None) - self.arm_template_display_name = kwargs.get('arm_template_display_name', None) - - -class DtlEnvironmentList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.DtlEnvironment] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DtlEnvironment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DtlEnvironmentList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class EnvironmentDeploymentProperties(msrest.serialization.Model): - """Properties of an environment deployment. - - :param arm_template_id: The Azure Resource Manager template's identifier. - :type arm_template_id: str - :param parameters: The parameters of the Azure Resource Manager template. - :type parameters: list[~azure.mgmt.devtestlabs.models.ArmTemplateParameterProperties] - """ - - _attribute_map = { - 'arm_template_id': {'key': 'armTemplateId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ArmTemplateParameterProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentDeploymentProperties, self).__init__(**kwargs) - self.arm_template_id = kwargs.get('arm_template_id', None) - self.parameters = kwargs.get('parameters', None) - - -class EnvironmentDeploymentPropertiesFragment(msrest.serialization.Model): - """Properties of an environment deployment. - - :param arm_template_id: The Azure Resource Manager template's identifier. - :type arm_template_id: str - :param parameters: The parameters of the Azure Resource Manager template. - :type parameters: list[~azure.mgmt.devtestlabs.models.ArmTemplateParameterPropertiesFragment] - """ - - _attribute_map = { - 'arm_template_id': {'key': 'armTemplateId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ArmTemplateParameterPropertiesFragment]'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentDeploymentPropertiesFragment, self).__init__(**kwargs) - self.arm_template_id = kwargs.get('arm_template_id', None) - self.parameters = kwargs.get('parameters', None) - - -class EvaluatePoliciesProperties(msrest.serialization.Model): - """Properties for evaluating a policy set. - - :param fact_name: The fact name. - :type fact_name: str - :param fact_data: The fact data. - :type fact_data: str - :param value_offset: The value offset. - :type value_offset: str - :param user_object_id: The user for which policies will be evaluated. - :type user_object_id: str - """ - - _attribute_map = { - 'fact_name': {'key': 'factName', 'type': 'str'}, - 'fact_data': {'key': 'factData', 'type': 'str'}, - 'value_offset': {'key': 'valueOffset', 'type': 'str'}, - 'user_object_id': {'key': 'userObjectId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EvaluatePoliciesProperties, self).__init__(**kwargs) - self.fact_name = kwargs.get('fact_name', None) - self.fact_data = kwargs.get('fact_data', None) - self.value_offset = kwargs.get('value_offset', None) - self.user_object_id = kwargs.get('user_object_id', None) - - -class EvaluatePoliciesRequest(msrest.serialization.Model): - """Request body for evaluating a policy set. - - :param policies: Policies to evaluate. - :type policies: list[~azure.mgmt.devtestlabs.models.EvaluatePoliciesProperties] - """ - - _attribute_map = { - 'policies': {'key': 'policies', 'type': '[EvaluatePoliciesProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(EvaluatePoliciesRequest, self).__init__(**kwargs) - self.policies = kwargs.get('policies', None) - - -class EvaluatePoliciesResponse(msrest.serialization.Model): - """Response body for evaluating a policy set. - - :param results: Results of evaluating a policy set. - :type results: list[~azure.mgmt.devtestlabs.models.PolicySetResult] - """ - - _attribute_map = { - 'results': {'key': 'results', 'type': '[PolicySetResult]'}, - } - - def __init__( - self, - **kwargs - ): - super(EvaluatePoliciesResponse, self).__init__(**kwargs) - self.results = kwargs.get('results', None) - - -class Event(msrest.serialization.Model): - """An event to be notified for. - - :param event_name: The event type for which this notification is enabled (i.e. AutoShutdown, - Cost). Possible values include: "AutoShutdown", "Cost". - :type event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType - """ - - _attribute_map = { - 'event_name': {'key': 'eventName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Event, self).__init__(**kwargs) - self.event_name = kwargs.get('event_name', None) - - -class EventFragment(msrest.serialization.Model): - """An event to be notified for. - - :param event_name: The event type for which this notification is enabled (i.e. AutoShutdown, - Cost). Possible values include: "AutoShutdown", "Cost". - :type event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType - """ - - _attribute_map = { - 'event_name': {'key': 'eventName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventFragment, self).__init__(**kwargs) - self.event_name = kwargs.get('event_name', None) - - -class ExportResourceUsageParameters(msrest.serialization.Model): - """The parameters of the export operation. - - :param blob_storage_absolute_sas_uri: The blob storage absolute sas uri with write permission - to the container which the usage data needs to be uploaded to. - :type blob_storage_absolute_sas_uri: str - :param usage_start_date: The start time of the usage. If not provided, usage will be reported - since the beginning of data collection. - :type usage_start_date: ~datetime.datetime - """ - - _attribute_map = { - 'blob_storage_absolute_sas_uri': {'key': 'blobStorageAbsoluteSasUri', 'type': 'str'}, - 'usage_start_date': {'key': 'usageStartDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ExportResourceUsageParameters, self).__init__(**kwargs) - self.blob_storage_absolute_sas_uri = kwargs.get('blob_storage_absolute_sas_uri', None) - self.usage_start_date = kwargs.get('usage_start_date', None) - - -class ExternalSubnet(msrest.serialization.Model): - """Subnet information as returned by the Microsoft.Network API. - - :param id: Gets or sets the identifier. - :type id: str - :param name: Gets or sets the name. - :type name: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExternalSubnet, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - - -class ExternalSubnetFragment(msrest.serialization.Model): - """Subnet information as returned by the Microsoft.Network API. - - :param id: Gets or sets the identifier. - :type id: str - :param name: Gets or sets the name. - :type name: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExternalSubnetFragment, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - - -class Formula(Resource): - """A formula for creating a VM, specifying an image base and other parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param description: The description of the formula. - :type description: str - :param author: The author of the formula. - :type author: str - :param os_type: The OS type of the formula. - :type os_type: str - :ivar creation_date: The creation date of the formula. - :vartype creation_date: ~datetime.datetime - :param formula_content: The content of the formula. - :type formula_content: ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameter - :param vm: Information about a VM from which a formula is to be created. - :type vm: ~azure.mgmt.devtestlabs.models.FormulaPropertiesFromVm - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'formula_content': {'key': 'properties.formulaContent', 'type': 'LabVirtualMachineCreationParameter'}, - 'vm': {'key': 'properties.vm', 'type': 'FormulaPropertiesFromVm'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Formula, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.author = kwargs.get('author', None) - self.os_type = kwargs.get('os_type', None) - self.creation_date = None - self.formula_content = kwargs.get('formula_content', None) - self.vm = kwargs.get('vm', None) - self.provisioning_state = None - self.unique_identifier = None - - -class FormulaFragment(UpdateResource): - """A formula for creating a VM, specifying an image base and other parameters. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param description: The description of the formula. - :type description: str - :param author: The author of the formula. - :type author: str - :param os_type: The OS type of the formula. - :type os_type: str - :param formula_content: The content of the formula. - :type formula_content: - ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameterFragment - :param vm: Information about a VM from which a formula is to be created. - :type vm: ~azure.mgmt.devtestlabs.models.FormulaPropertiesFromVmFragment - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'formula_content': {'key': 'properties.formulaContent', 'type': 'LabVirtualMachineCreationParameterFragment'}, - 'vm': {'key': 'properties.vm', 'type': 'FormulaPropertiesFromVmFragment'}, - } - - def __init__( - self, - **kwargs - ): - super(FormulaFragment, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.author = kwargs.get('author', None) - self.os_type = kwargs.get('os_type', None) - self.formula_content = kwargs.get('formula_content', None) - self.vm = kwargs.get('vm', None) - - -class FormulaList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Formula] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Formula]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FormulaList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class FormulaPropertiesFromVm(msrest.serialization.Model): - """Information about a VM from which a formula is to be created. - - :param lab_vm_id: The identifier of the VM from which a formula is to be created. - :type lab_vm_id: str - """ - - _attribute_map = { - 'lab_vm_id': {'key': 'labVmId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FormulaPropertiesFromVm, self).__init__(**kwargs) - self.lab_vm_id = kwargs.get('lab_vm_id', None) - - -class FormulaPropertiesFromVmFragment(msrest.serialization.Model): - """Information about a VM from which a formula is to be created. - - :param lab_vm_id: The identifier of the VM from which a formula is to be created. - :type lab_vm_id: str - """ - - _attribute_map = { - 'lab_vm_id': {'key': 'labVmId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FormulaPropertiesFromVmFragment, self).__init__(**kwargs) - self.lab_vm_id = kwargs.get('lab_vm_id', None) - - -class GalleryImage(Resource): - """A gallery image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param author: The author of the gallery image. - :type author: str - :ivar created_date: The creation date of the gallery image. - :vartype created_date: ~datetime.datetime - :param description: The description of the gallery image. - :type description: str - :param image_reference: The image reference of the gallery image. - :type image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference - :param icon: The icon of the gallery image. - :type icon: str - :param enabled: Indicates whether this gallery image is enabled. - :type enabled: bool - :param plan_id: The third party plan that applies to this image. - :type plan_id: str - :param is_plan_authorized: Indicates if the plan has been authorized for programmatic - deployment. - :type is_plan_authorized: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date': {'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}'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'image_reference': {'key': 'properties.imageReference', 'type': 'GalleryImageReference'}, - 'icon': {'key': 'properties.icon', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'is_plan_authorized': {'key': 'properties.isPlanAuthorized', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(GalleryImage, self).__init__(**kwargs) - self.author = kwargs.get('author', None) - self.created_date = None - self.description = kwargs.get('description', None) - self.image_reference = kwargs.get('image_reference', None) - self.icon = kwargs.get('icon', None) - self.enabled = kwargs.get('enabled', None) - self.plan_id = kwargs.get('plan_id', None) - self.is_plan_authorized = kwargs.get('is_plan_authorized', None) - - -class GalleryImageList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.GalleryImage] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GalleryImage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GalleryImageList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class GalleryImageReference(msrest.serialization.Model): - """The reference information for an Azure Marketplace image. - - :param offer: The offer of the gallery image. - :type offer: str - :param publisher: The publisher of the gallery image. - :type publisher: str - :param sku: The SKU of the gallery image. - :type sku: str - :param os_type: The OS type of the gallery image. - :type os_type: str - :param version: The version of the gallery image. - :type version: str - """ - - _attribute_map = { - 'offer': {'key': 'offer', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GalleryImageReference, self).__init__(**kwargs) - self.offer = kwargs.get('offer', None) - self.publisher = kwargs.get('publisher', None) - self.sku = kwargs.get('sku', None) - self.os_type = kwargs.get('os_type', None) - self.version = kwargs.get('version', None) - - -class GalleryImageReferenceFragment(msrest.serialization.Model): - """The reference information for an Azure Marketplace image. - - :param offer: The offer of the gallery image. - :type offer: str - :param publisher: The publisher of the gallery image. - :type publisher: str - :param sku: The SKU of the gallery image. - :type sku: str - :param os_type: The OS type of the gallery image. - :type os_type: str - :param version: The version of the gallery image. - :type version: str - """ - - _attribute_map = { - 'offer': {'key': 'offer', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GalleryImageReferenceFragment, self).__init__(**kwargs) - self.offer = kwargs.get('offer', None) - self.publisher = kwargs.get('publisher', None) - self.sku = kwargs.get('sku', None) - self.os_type = kwargs.get('os_type', None) - self.version = kwargs.get('version', None) - - -class GenerateArmTemplateRequest(msrest.serialization.Model): - """Parameters for generating an ARM template for deploying artifacts. - - :param virtual_machine_name: The resource name of the virtual machine. - :type virtual_machine_name: str - :param parameters: The parameters of the ARM template. - :type parameters: list[~azure.mgmt.devtestlabs.models.ParameterInfo] - :param location: The location of the virtual machine. - :type location: str - :param file_upload_options: Options for uploading the files for the artifact. - UploadFilesAndGenerateSasTokens is the default value. Possible values include: - "UploadFilesAndGenerateSasTokens", "None". - :type file_upload_options: str or ~azure.mgmt.devtestlabs.models.FileUploadOptions - """ - - _attribute_map = { - 'virtual_machine_name': {'key': 'virtualMachineName', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ParameterInfo]'}, - 'location': {'key': 'location', 'type': 'str'}, - 'file_upload_options': {'key': 'fileUploadOptions', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GenerateArmTemplateRequest, self).__init__(**kwargs) - self.virtual_machine_name = kwargs.get('virtual_machine_name', None) - self.parameters = kwargs.get('parameters', None) - self.location = kwargs.get('location', None) - self.file_upload_options = kwargs.get('file_upload_options', None) - - -class GenerateUploadUriParameter(msrest.serialization.Model): - """Properties for generating an upload URI. - - :param blob_name: The blob name of the upload URI. - :type blob_name: str - """ - - _attribute_map = { - 'blob_name': {'key': 'blobName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GenerateUploadUriParameter, self).__init__(**kwargs) - self.blob_name = kwargs.get('blob_name', None) - - -class GenerateUploadUriResponse(msrest.serialization.Model): - """Response body for generating an upload URI. - - :param upload_uri: The upload URI for the VHD. - :type upload_uri: str - """ - - _attribute_map = { - 'upload_uri': {'key': 'uploadUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GenerateUploadUriResponse, self).__init__(**kwargs) - self.upload_uri = kwargs.get('upload_uri', None) - - -class HourDetails(msrest.serialization.Model): - """Properties of an hourly schedule. - - :param minute: Minutes of the hour the schedule will run. - :type minute: int - """ - - _attribute_map = { - 'minute': {'key': 'minute', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(HourDetails, self).__init__(**kwargs) - self.minute = kwargs.get('minute', None) - - -class HourDetailsFragment(msrest.serialization.Model): - """Properties of an hourly schedule. - - :param minute: Minutes of the hour the schedule will run. - :type minute: int - """ - - _attribute_map = { - 'minute': {'key': 'minute', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(HourDetailsFragment, self).__init__(**kwargs) - self.minute = kwargs.get('minute', None) - - -class IdentityProperties(msrest.serialization.Model): - """Properties of a managed identity. - - :param type: Managed identity. - :type type: str - :param principal_id: The principal id of resource identity. - :type principal_id: str - :param tenant_id: The tenant identifier of resource. - :type tenant_id: str - :param client_secret_url: The client secret URL of the identity. - :type client_secret_url: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'client_secret_url': {'key': 'clientSecretUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentityProperties, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.principal_id = kwargs.get('principal_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.client_secret_url = kwargs.get('client_secret_url', None) - - -class ImportLabVirtualMachineRequest(msrest.serialization.Model): - """This represents the payload required to import a virtual machine from a different lab into the current one. - - :param source_virtual_machine_resource_id: The full resource ID of the virtual machine to be - imported. - :type source_virtual_machine_resource_id: str - :param destination_virtual_machine_name: The name of the virtual machine in the destination - lab. - :type destination_virtual_machine_name: str - """ - - _attribute_map = { - 'source_virtual_machine_resource_id': {'key': 'sourceVirtualMachineResourceId', 'type': 'str'}, - 'destination_virtual_machine_name': {'key': 'destinationVirtualMachineName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ImportLabVirtualMachineRequest, self).__init__(**kwargs) - self.source_virtual_machine_resource_id = kwargs.get('source_virtual_machine_resource_id', None) - self.destination_virtual_machine_name = kwargs.get('destination_virtual_machine_name', None) - - -class InboundNatRule(msrest.serialization.Model): - """A rule for NAT - exposing a VM's port (backendPort) on the public IP address using a load balancer. - - :param transport_protocol: The transport protocol for the endpoint. Possible values include: - "Tcp", "Udp". - :type transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol - :param frontend_port: The external endpoint port of the inbound connection. Possible values - range between 1 and 65535, inclusive. If unspecified, a value will be allocated automatically. - :type frontend_port: int - :param backend_port: The port to which the external traffic will be redirected. - :type backend_port: int - """ - - _attribute_map = { - 'transport_protocol': {'key': 'transportProtocol', 'type': 'str'}, - 'frontend_port': {'key': 'frontendPort', 'type': 'int'}, - 'backend_port': {'key': 'backendPort', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(InboundNatRule, self).__init__(**kwargs) - self.transport_protocol = kwargs.get('transport_protocol', None) - self.frontend_port = kwargs.get('frontend_port', None) - self.backend_port = kwargs.get('backend_port', None) - - -class InboundNatRuleFragment(msrest.serialization.Model): - """A rule for NAT - exposing a VM's port (backendPort) on the public IP address using a load balancer. - - :param transport_protocol: The transport protocol for the endpoint. Possible values include: - "Tcp", "Udp". - :type transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol - :param frontend_port: The external endpoint port of the inbound connection. Possible values - range between 1 and 65535, inclusive. If unspecified, a value will be allocated automatically. - :type frontend_port: int - :param backend_port: The port to which the external traffic will be redirected. - :type backend_port: int - """ - - _attribute_map = { - 'transport_protocol': {'key': 'transportProtocol', 'type': 'str'}, - 'frontend_port': {'key': 'frontendPort', 'type': 'int'}, - 'backend_port': {'key': 'backendPort', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(InboundNatRuleFragment, self).__init__(**kwargs) - self.transport_protocol = kwargs.get('transport_protocol', None) - self.frontend_port = kwargs.get('frontend_port', None) - self.backend_port = kwargs.get('backend_port', None) - - -class Lab(Resource): - """A lab. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :ivar default_storage_account: The lab's default storage account. - :vartype default_storage_account: str - :ivar default_premium_storage_account: The lab's default premium storage account. - :vartype default_premium_storage_account: str - :ivar artifacts_storage_account: The lab's artifact storage account. - :vartype artifacts_storage_account: str - :ivar premium_data_disk_storage_account: The lab's premium data disk storage account. - :vartype premium_data_disk_storage_account: str - :ivar vault_name: The lab's Key vault. - :vartype vault_name: str - :param lab_storage_type: Type of storage used by the lab. It can be either Premium or Standard. - Default is Premium. Possible values include: "Standard", "Premium", "StandardSSD". - :type lab_storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType - :param mandatory_artifacts_resource_ids_linux: The ordered list of artifact resource IDs that - should be applied on all Linux VM creations by default, prior to the artifacts specified by the - user. - :type mandatory_artifacts_resource_ids_linux: list[str] - :param mandatory_artifacts_resource_ids_windows: The ordered list of artifact resource IDs that - should be applied on all Windows VM creations by default, prior to the artifacts specified by - the user. - :type mandatory_artifacts_resource_ids_windows: list[str] - :ivar created_date: The creation date of the lab. - :vartype created_date: ~datetime.datetime - :param premium_data_disks: The setting to enable usage of premium data disks. - When its value is 'Enabled', creation of standard or premium data disks is allowed. - When its value is 'Disabled', only creation of standard data disks is allowed. Possible values - include: "Disabled", "Enabled". - :type premium_data_disks: str or ~azure.mgmt.devtestlabs.models.PremiumDataDisk - :param environment_permission: The access rights to be granted to the user when provisioning an - environment. Possible values include: "Reader", "Contributor". - :type environment_permission: str or ~azure.mgmt.devtestlabs.models.EnvironmentPermission - :param announcement: The properties of any lab announcement associated with this lab. - :type announcement: ~azure.mgmt.devtestlabs.models.LabAnnouncementProperties - :param support: The properties of any lab support message associated with this lab. - :type support: ~azure.mgmt.devtestlabs.models.LabSupportProperties - :ivar vm_creation_resource_group: The resource group in which all new lab virtual machines will - be created. To let DevTest Labs manage resource group creation, set this value to null. - :vartype vm_creation_resource_group: str - :ivar public_ip_id: The public IP address for the lab's load balancer. - :vartype public_ip_id: str - :ivar load_balancer_id: The load balancer used to for lab VMs that use shared IP address. - :vartype load_balancer_id: str - :ivar network_security_group_id: The Network Security Group attached to the lab VMs Network - interfaces to restrict open ports. - :vartype network_security_group_id: str - :param extended_properties: Extended properties of the lab used for experimental features. - :type extended_properties: dict[str, str] - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'default_storage_account': {'readonly': True}, - 'default_premium_storage_account': {'readonly': True}, - 'artifacts_storage_account': {'readonly': True}, - 'premium_data_disk_storage_account': {'readonly': True}, - 'vault_name': {'readonly': True}, - 'created_date': {'readonly': True}, - 'vm_creation_resource_group': {'readonly': True}, - 'public_ip_id': {'readonly': True}, - 'load_balancer_id': {'readonly': True}, - 'network_security_group_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'default_storage_account': {'key': 'properties.defaultStorageAccount', 'type': 'str'}, - 'default_premium_storage_account': {'key': 'properties.defaultPremiumStorageAccount', 'type': 'str'}, - 'artifacts_storage_account': {'key': 'properties.artifactsStorageAccount', 'type': 'str'}, - 'premium_data_disk_storage_account': {'key': 'properties.premiumDataDiskStorageAccount', 'type': 'str'}, - 'vault_name': {'key': 'properties.vaultName', 'type': 'str'}, - 'lab_storage_type': {'key': 'properties.labStorageType', 'type': 'str'}, - 'mandatory_artifacts_resource_ids_linux': {'key': 'properties.mandatoryArtifactsResourceIdsLinux', 'type': '[str]'}, - 'mandatory_artifacts_resource_ids_windows': {'key': 'properties.mandatoryArtifactsResourceIdsWindows', 'type': '[str]'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'premium_data_disks': {'key': 'properties.premiumDataDisks', 'type': 'str'}, - 'environment_permission': {'key': 'properties.environmentPermission', 'type': 'str'}, - 'announcement': {'key': 'properties.announcement', 'type': 'LabAnnouncementProperties'}, - 'support': {'key': 'properties.support', 'type': 'LabSupportProperties'}, - 'vm_creation_resource_group': {'key': 'properties.vmCreationResourceGroup', 'type': 'str'}, - 'public_ip_id': {'key': 'properties.publicIpId', 'type': 'str'}, - 'load_balancer_id': {'key': 'properties.loadBalancerId', 'type': 'str'}, - 'network_security_group_id': {'key': 'properties.networkSecurityGroupId', 'type': 'str'}, - 'extended_properties': {'key': 'properties.extendedProperties', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Lab, self).__init__(**kwargs) - self.default_storage_account = None - self.default_premium_storage_account = None - self.artifacts_storage_account = None - self.premium_data_disk_storage_account = None - self.vault_name = None - self.lab_storage_type = kwargs.get('lab_storage_type', None) - self.mandatory_artifacts_resource_ids_linux = kwargs.get('mandatory_artifacts_resource_ids_linux', None) - self.mandatory_artifacts_resource_ids_windows = kwargs.get('mandatory_artifacts_resource_ids_windows', None) - self.created_date = None - self.premium_data_disks = kwargs.get('premium_data_disks', None) - self.environment_permission = kwargs.get('environment_permission', None) - self.announcement = kwargs.get('announcement', None) - self.support = kwargs.get('support', None) - self.vm_creation_resource_group = None - self.public_ip_id = None - self.load_balancer_id = None - self.network_security_group_id = None - self.extended_properties = kwargs.get('extended_properties', None) - self.provisioning_state = None - self.unique_identifier = None - - -class LabAnnouncementProperties(msrest.serialization.Model): - """Properties of a lab's announcement banner. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param title: The plain text title for the lab announcement. - :type title: str - :param markdown: The markdown text (if any) that this lab displays in the UI. If left - empty/null, nothing will be shown. - :type markdown: str - :param enabled: Is the lab announcement active/enabled at this time?. Possible values include: - "Enabled", "Disabled". - :type enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param expiration_date: The time at which the announcement expires (null for never). - :type expiration_date: ~datetime.datetime - :param expired: Has this announcement expired?. - :type expired: bool - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'readonly': True}, - } - - _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'markdown': {'key': 'markdown', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'iso-8601'}, - 'expired': {'key': 'expired', 'type': 'bool'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabAnnouncementProperties, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.markdown = kwargs.get('markdown', None) - self.enabled = kwargs.get('enabled', None) - self.expiration_date = kwargs.get('expiration_date', None) - self.expired = kwargs.get('expired', None) - self.provisioning_state = None - self.unique_identifier = None - - -class LabAnnouncementPropertiesFragment(msrest.serialization.Model): - """Properties of a lab's announcement banner. - - :param title: The plain text title for the lab announcement. - :type title: str - :param markdown: The markdown text (if any) that this lab displays in the UI. If left - empty/null, nothing will be shown. - :type markdown: str - :param enabled: Is the lab announcement active/enabled at this time?. Possible values include: - "Enabled", "Disabled". - :type enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param expiration_date: The time at which the announcement expires (null for never). - :type expiration_date: ~datetime.datetime - :param expired: Has this announcement expired?. - :type expired: bool - """ - - _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'markdown': {'key': 'markdown', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'iso-8601'}, - 'expired': {'key': 'expired', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(LabAnnouncementPropertiesFragment, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.markdown = kwargs.get('markdown', None) - self.enabled = kwargs.get('enabled', None) - self.expiration_date = kwargs.get('expiration_date', None) - self.expired = kwargs.get('expired', None) - - -class LabCost(Resource): - """A cost item. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param target_cost: The target cost properties. - :type target_cost: ~azure.mgmt.devtestlabs.models.TargetCostProperties - :ivar lab_cost_summary: The lab cost summary component of the cost data. - :vartype lab_cost_summary: ~azure.mgmt.devtestlabs.models.LabCostSummaryProperties - :ivar lab_cost_details: The lab cost details component of the cost data. - :vartype lab_cost_details: list[~azure.mgmt.devtestlabs.models.LabCostDetailsProperties] - :ivar resource_costs: The resource cost component of the cost data. - :vartype resource_costs: list[~azure.mgmt.devtestlabs.models.LabResourceCostProperties] - :param currency_code: The currency code of the cost. - :type currency_code: str - :param start_date_time: The start time of the cost data. - :type start_date_time: ~datetime.datetime - :param end_date_time: The end time of the cost data. - :type end_date_time: ~datetime.datetime - :param created_date: The creation date of the cost. - :type created_date: ~datetime.datetime - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'lab_cost_summary': {'readonly': True}, - 'lab_cost_details': {'readonly': True}, - 'resource_costs': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'target_cost': {'key': 'properties.targetCost', 'type': 'TargetCostProperties'}, - 'lab_cost_summary': {'key': 'properties.labCostSummary', 'type': 'LabCostSummaryProperties'}, - 'lab_cost_details': {'key': 'properties.labCostDetails', 'type': '[LabCostDetailsProperties]'}, - 'resource_costs': {'key': 'properties.resourceCosts', 'type': '[LabResourceCostProperties]'}, - 'currency_code': {'key': 'properties.currencyCode', 'type': 'str'}, - 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, - 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabCost, self).__init__(**kwargs) - self.target_cost = kwargs.get('target_cost', None) - self.lab_cost_summary = None - self.lab_cost_details = None - self.resource_costs = None - self.currency_code = kwargs.get('currency_code', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.created_date = kwargs.get('created_date', None) - self.provisioning_state = None - self.unique_identifier = None - - -class LabCostDetailsProperties(msrest.serialization.Model): - """The properties of a lab cost item. - - :param date: The date of the cost item. - :type date: ~datetime.datetime - :param cost: The cost component of the cost item. - :type cost: float - :param cost_type: The type of the cost. Possible values include: "Unavailable", "Reported", - "Projected". - :type cost_type: str or ~azure.mgmt.devtestlabs.models.CostType - """ - - _attribute_map = { - 'date': {'key': 'date', 'type': 'iso-8601'}, - 'cost': {'key': 'cost', 'type': 'float'}, - 'cost_type': {'key': 'costType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabCostDetailsProperties, self).__init__(**kwargs) - self.date = kwargs.get('date', None) - self.cost = kwargs.get('cost', None) - self.cost_type = kwargs.get('cost_type', None) - - -class LabCostSummaryProperties(msrest.serialization.Model): - """The properties of the cost summary. - - :param estimated_lab_cost: The cost component of the cost item. - :type estimated_lab_cost: float - """ - - _attribute_map = { - 'estimated_lab_cost': {'key': 'estimatedLabCost', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(LabCostSummaryProperties, self).__init__(**kwargs) - self.estimated_lab_cost = kwargs.get('estimated_lab_cost', None) - - -class LabFragment(UpdateResource): - """A lab. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param lab_storage_type: Type of storage used by the lab. It can be either Premium or Standard. - Default is Premium. Possible values include: "Standard", "Premium", "StandardSSD". - :type lab_storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType - :param mandatory_artifacts_resource_ids_linux: The ordered list of artifact resource IDs that - should be applied on all Linux VM creations by default, prior to the artifacts specified by the - user. - :type mandatory_artifacts_resource_ids_linux: list[str] - :param mandatory_artifacts_resource_ids_windows: The ordered list of artifact resource IDs that - should be applied on all Windows VM creations by default, prior to the artifacts specified by - the user. - :type mandatory_artifacts_resource_ids_windows: list[str] - :param premium_data_disks: The setting to enable usage of premium data disks. - When its value is 'Enabled', creation of standard or premium data disks is allowed. - When its value is 'Disabled', only creation of standard data disks is allowed. Possible values - include: "Disabled", "Enabled". - :type premium_data_disks: str or ~azure.mgmt.devtestlabs.models.PremiumDataDisk - :param environment_permission: The access rights to be granted to the user when provisioning an - environment. Possible values include: "Reader", "Contributor". - :type environment_permission: str or ~azure.mgmt.devtestlabs.models.EnvironmentPermission - :param announcement: The properties of any lab announcement associated with this lab. - :type announcement: ~azure.mgmt.devtestlabs.models.LabAnnouncementPropertiesFragment - :param support: The properties of any lab support message associated with this lab. - :type support: ~azure.mgmt.devtestlabs.models.LabSupportPropertiesFragment - :param extended_properties: Extended properties of the lab used for experimental features. - :type extended_properties: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'lab_storage_type': {'key': 'properties.labStorageType', 'type': 'str'}, - 'mandatory_artifacts_resource_ids_linux': {'key': 'properties.mandatoryArtifactsResourceIdsLinux', 'type': '[str]'}, - 'mandatory_artifacts_resource_ids_windows': {'key': 'properties.mandatoryArtifactsResourceIdsWindows', 'type': '[str]'}, - 'premium_data_disks': {'key': 'properties.premiumDataDisks', 'type': 'str'}, - 'environment_permission': {'key': 'properties.environmentPermission', 'type': 'str'}, - 'announcement': {'key': 'properties.announcement', 'type': 'LabAnnouncementPropertiesFragment'}, - 'support': {'key': 'properties.support', 'type': 'LabSupportPropertiesFragment'}, - 'extended_properties': {'key': 'properties.extendedProperties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(LabFragment, self).__init__(**kwargs) - self.lab_storage_type = kwargs.get('lab_storage_type', None) - self.mandatory_artifacts_resource_ids_linux = kwargs.get('mandatory_artifacts_resource_ids_linux', None) - self.mandatory_artifacts_resource_ids_windows = kwargs.get('mandatory_artifacts_resource_ids_windows', None) - self.premium_data_disks = kwargs.get('premium_data_disks', None) - self.environment_permission = kwargs.get('environment_permission', None) - self.announcement = kwargs.get('announcement', None) - self.support = kwargs.get('support', None) - self.extended_properties = kwargs.get('extended_properties', None) - - -class LabList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Lab] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Lab]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class LabResourceCostProperties(msrest.serialization.Model): - """The properties of a resource cost item. - - :param resourcename: The name of the resource. - :type resourcename: str - :param resource_u_id: The unique identifier of the resource. - :type resource_u_id: str - :param resource_cost: The cost component of the resource cost item. - :type resource_cost: float - :param resource_type: The logical resource type (ex. virtualmachine, storageaccount). - :type resource_type: str - :param resource_owner: The owner of the resource (ex. janedoe@microsoft.com). - :type resource_owner: str - :param resource_pricing_tier: The category of the resource (ex. Premium_LRS, Standard_DS1). - :type resource_pricing_tier: str - :param resource_status: The status of the resource (ex. Active). - :type resource_status: str - :param resource_id: The ID of the resource. - :type resource_id: str - :param external_resource_id: The ID of the external resource. - :type external_resource_id: str - """ - - _attribute_map = { - 'resourcename': {'key': 'resourcename', 'type': 'str'}, - 'resource_u_id': {'key': 'resourceUId', 'type': 'str'}, - 'resource_cost': {'key': 'resourceCost', 'type': 'float'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_owner': {'key': 'resourceOwner', 'type': 'str'}, - 'resource_pricing_tier': {'key': 'resourcePricingTier', 'type': 'str'}, - 'resource_status': {'key': 'resourceStatus', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'external_resource_id': {'key': 'externalResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabResourceCostProperties, self).__init__(**kwargs) - self.resourcename = kwargs.get('resourcename', None) - self.resource_u_id = kwargs.get('resource_u_id', None) - self.resource_cost = kwargs.get('resource_cost', None) - self.resource_type = kwargs.get('resource_type', None) - self.resource_owner = kwargs.get('resource_owner', None) - self.resource_pricing_tier = kwargs.get('resource_pricing_tier', None) - self.resource_status = kwargs.get('resource_status', None) - self.resource_id = kwargs.get('resource_id', None) - self.external_resource_id = kwargs.get('external_resource_id', None) - - -class LabSupportProperties(msrest.serialization.Model): - """Properties of a lab's support banner. - - :param enabled: Is the lab support banner active/enabled at this time?. Possible values - include: "Enabled", "Disabled". - :type enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param markdown: The markdown text (if any) that this lab displays in the UI. If left - empty/null, nothing will be shown. - :type markdown: str - """ - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'str'}, - 'markdown': {'key': 'markdown', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabSupportProperties, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - self.markdown = kwargs.get('markdown', None) - - -class LabSupportPropertiesFragment(msrest.serialization.Model): - """Properties of a lab's support banner. - - :param enabled: Is the lab support banner active/enabled at this time?. Possible values - include: "Enabled", "Disabled". - :type enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param markdown: The markdown text (if any) that this lab displays in the UI. If left - empty/null, nothing will be shown. - :type markdown: str - """ - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'str'}, - 'markdown': {'key': 'markdown', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabSupportPropertiesFragment, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - self.markdown = kwargs.get('markdown', None) - - -class LabVhd(msrest.serialization.Model): - """Properties of a VHD in the lab. - - :param id: The URI to the VHD. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabVhd, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class LabVhdList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.LabVhd] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[LabVhd]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabVhdList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class LabVirtualMachine(Resource): - """A virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param notes: The notes of the virtual machine. - :type notes: str - :param owner_object_id: The object identifier of the owner of the virtual machine. - :type owner_object_id: str - :param owner_user_principal_name: The user principal name of the virtual machine owner. - :type owner_user_principal_name: str - :param created_by_user_id: The object identifier of the creator of the virtual machine. - :type created_by_user_id: str - :param created_by_user: The email address of creator of the virtual machine. - :type created_by_user: str - :param created_date: The creation date of the virtual machine. - :type created_date: ~datetime.datetime - :param compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. - :type compute_id: str - :param custom_image_id: The custom image identifier of the virtual machine. - :type custom_image_id: str - :param os_type: The OS type of the virtual machine. - :type os_type: str - :param size: The size of the virtual machine. - :type size: str - :param user_name: The user name of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine administrator. - :type password: str - :param ssh_key: The SSH key of the virtual machine administrator. - :type ssh_key: str - :param is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key - for authentication. - :type is_authentication_with_ssh_key: bool - :param fqdn: The fully-qualified domain name of the virtual machine. - :type fqdn: str - :param lab_subnet_name: The lab subnet name of the virtual machine. - :type lab_subnet_name: str - :param lab_virtual_network_id: The lab virtual network identifier of the virtual machine. - :type lab_virtual_network_id: str - :param disallow_public_ip_address: Indicates whether the virtual machine is to be created - without a public IP address. - :type disallow_public_ip_address: bool - :param artifacts: The artifacts to be installed on the virtual machine. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] - :param artifact_deployment_status: The artifact deployment status for the virtual machine. - :type artifact_deployment_status: - ~azure.mgmt.devtestlabs.models.ArtifactDeploymentStatusProperties - :param gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual - machine. - :type gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference - :param plan_id: The id of the plan associated with the virtual machine image. - :type plan_id: str - :ivar compute_vm: The compute virtual machine properties. - :vartype compute_vm: ~azure.mgmt.devtestlabs.models.ComputeVmProperties - :param network_interface: The network interface properties. - :type network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfaceProperties - :ivar applicable_schedule: The applicable schedule for the virtual machine. - :vartype applicable_schedule: ~azure.mgmt.devtestlabs.models.ApplicableSchedule - :param expiration_date: The expiration date for VM. - :type expiration_date: ~datetime.datetime - :param allow_claim: Indicates whether another user can take ownership of the virtual machine. - :type allow_claim: bool - :param storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). - :type storage_type: str - :param virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output - property only. Possible values include: "FromCustomImage", "FromGalleryImage", - "FromSharedGalleryImage". - :type virtual_machine_creation_source: str or - ~azure.mgmt.devtestlabs.models.VirtualMachineCreationSource - :param environment_id: The resource ID of the environment that contains this virtual machine, - if any. - :type environment_id: str - :param data_disk_parameters: New or existing data disks to attach to the virtual machine after - creation. - :type data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskProperties] - :param schedule_parameters: Virtual Machine schedules to be created. - :type schedule_parameters: list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameter] - :param last_known_power_state: Last known compute power state captured in DTL. - :type last_known_power_state: str - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'compute_vm': {'readonly': True}, - 'applicable_schedule': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owner_object_id': {'key': 'properties.ownerObjectId', 'type': 'str'}, - 'owner_user_principal_name': {'key': 'properties.ownerUserPrincipalName', 'type': 'str'}, - 'created_by_user_id': {'key': 'properties.createdByUserId', 'type': 'str'}, - 'created_by_user': {'key': 'properties.createdByUser', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'compute_id': {'key': 'properties.computeId', 'type': 'str'}, - 'custom_image_id': {'key': 'properties.customImageId', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'size': {'key': 'properties.size', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'ssh_key': {'key': 'properties.sshKey', 'type': 'str'}, - 'is_authentication_with_ssh_key': {'key': 'properties.isAuthenticationWithSshKey', 'type': 'bool'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'lab_subnet_name': {'key': 'properties.labSubnetName', 'type': 'str'}, - 'lab_virtual_network_id': {'key': 'properties.labVirtualNetworkId', 'type': 'str'}, - 'disallow_public_ip_address': {'key': 'properties.disallowPublicIpAddress', 'type': 'bool'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[ArtifactInstallProperties]'}, - 'artifact_deployment_status': {'key': 'properties.artifactDeploymentStatus', 'type': 'ArtifactDeploymentStatusProperties'}, - 'gallery_image_reference': {'key': 'properties.galleryImageReference', 'type': 'GalleryImageReference'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'compute_vm': {'key': 'properties.computeVm', 'type': 'ComputeVmProperties'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterfaceProperties'}, - 'applicable_schedule': {'key': 'properties.applicableSchedule', 'type': 'ApplicableSchedule'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'allow_claim': {'key': 'properties.allowClaim', 'type': 'bool'}, - 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, - 'virtual_machine_creation_source': {'key': 'properties.virtualMachineCreationSource', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - 'data_disk_parameters': {'key': 'properties.dataDiskParameters', 'type': '[DataDiskProperties]'}, - 'schedule_parameters': {'key': 'properties.scheduleParameters', 'type': '[ScheduleCreationParameter]'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabVirtualMachine, self).__init__(**kwargs) - self.notes = kwargs.get('notes', None) - self.owner_object_id = kwargs.get('owner_object_id', None) - self.owner_user_principal_name = kwargs.get('owner_user_principal_name', None) - self.created_by_user_id = kwargs.get('created_by_user_id', None) - self.created_by_user = kwargs.get('created_by_user', None) - self.created_date = kwargs.get('created_date', None) - self.compute_id = kwargs.get('compute_id', None) - self.custom_image_id = kwargs.get('custom_image_id', None) - self.os_type = kwargs.get('os_type', None) - self.size = kwargs.get('size', None) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - self.ssh_key = kwargs.get('ssh_key', None) - self.is_authentication_with_ssh_key = kwargs.get('is_authentication_with_ssh_key', None) - self.fqdn = kwargs.get('fqdn', None) - self.lab_subnet_name = kwargs.get('lab_subnet_name', None) - self.lab_virtual_network_id = kwargs.get('lab_virtual_network_id', None) - self.disallow_public_ip_address = kwargs.get('disallow_public_ip_address', None) - self.artifacts = kwargs.get('artifacts', None) - self.artifact_deployment_status = kwargs.get('artifact_deployment_status', None) - self.gallery_image_reference = kwargs.get('gallery_image_reference', None) - self.plan_id = kwargs.get('plan_id', None) - self.compute_vm = None - self.network_interface = kwargs.get('network_interface', None) - self.applicable_schedule = None - self.expiration_date = kwargs.get('expiration_date', None) - self.allow_claim = kwargs.get('allow_claim', None) - self.storage_type = kwargs.get('storage_type', None) - self.virtual_machine_creation_source = kwargs.get('virtual_machine_creation_source', None) - self.environment_id = kwargs.get('environment_id', None) - self.data_disk_parameters = kwargs.get('data_disk_parameters', None) - self.schedule_parameters = kwargs.get('schedule_parameters', None) - self.last_known_power_state = kwargs.get('last_known_power_state', None) - self.provisioning_state = None - self.unique_identifier = None - - -class LabVirtualMachineCreationParameter(msrest.serialization.Model): - """Properties for creating a virtual machine. - - :param name: The name of the virtual machine or environment. - :type name: str - :param location: The location of the new virtual machine or environment. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param bulk_creation_parameters: The number of virtual machine instances to create. - :type bulk_creation_parameters: ~azure.mgmt.devtestlabs.models.BulkCreationParameters - :param notes: The notes of the virtual machine. - :type notes: str - :param owner_object_id: The object identifier of the owner of the virtual machine. - :type owner_object_id: str - :param owner_user_principal_name: The user principal name of the virtual machine owner. - :type owner_user_principal_name: str - :param created_by_user_id: The object identifier of the creator of the virtual machine. - :type created_by_user_id: str - :param created_by_user: The email address of creator of the virtual machine. - :type created_by_user: str - :param created_date: The creation date of the virtual machine. - :type created_date: ~datetime.datetime - :param compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. - :type compute_id: str - :param custom_image_id: The custom image identifier of the virtual machine. - :type custom_image_id: str - :param os_type: The OS type of the virtual machine. - :type os_type: str - :param size: The size of the virtual machine. - :type size: str - :param user_name: The user name of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine administrator. - :type password: str - :param ssh_key: The SSH key of the virtual machine administrator. - :type ssh_key: str - :param is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key - for authentication. - :type is_authentication_with_ssh_key: bool - :param fqdn: The fully-qualified domain name of the virtual machine. - :type fqdn: str - :param lab_subnet_name: The lab subnet name of the virtual machine. - :type lab_subnet_name: str - :param lab_virtual_network_id: The lab virtual network identifier of the virtual machine. - :type lab_virtual_network_id: str - :param disallow_public_ip_address: Indicates whether the virtual machine is to be created - without a public IP address. - :type disallow_public_ip_address: bool - :param artifacts: The artifacts to be installed on the virtual machine. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] - :param artifact_deployment_status: The artifact deployment status for the virtual machine. - :type artifact_deployment_status: - ~azure.mgmt.devtestlabs.models.ArtifactDeploymentStatusProperties - :param gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual - machine. - :type gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference - :param plan_id: The id of the plan associated with the virtual machine image. - :type plan_id: str - :param network_interface: The network interface properties. - :type network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfaceProperties - :param expiration_date: The expiration date for VM. - :type expiration_date: ~datetime.datetime - :param allow_claim: Indicates whether another user can take ownership of the virtual machine. - :type allow_claim: bool - :param storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). - :type storage_type: str - :param virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output - property only. Possible values include: "FromCustomImage", "FromGalleryImage", - "FromSharedGalleryImage". - :type virtual_machine_creation_source: str or - ~azure.mgmt.devtestlabs.models.VirtualMachineCreationSource - :param environment_id: The resource ID of the environment that contains this virtual machine, - if any. - :type environment_id: str - :param data_disk_parameters: New or existing data disks to attach to the virtual machine after - creation. - :type data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskProperties] - :param schedule_parameters: Virtual Machine schedules to be created. - :type schedule_parameters: list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameter] - :param last_known_power_state: Last known compute power state captured in DTL. - :type last_known_power_state: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'bulk_creation_parameters': {'key': 'properties.bulkCreationParameters', 'type': 'BulkCreationParameters'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owner_object_id': {'key': 'properties.ownerObjectId', 'type': 'str'}, - 'owner_user_principal_name': {'key': 'properties.ownerUserPrincipalName', 'type': 'str'}, - 'created_by_user_id': {'key': 'properties.createdByUserId', 'type': 'str'}, - 'created_by_user': {'key': 'properties.createdByUser', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'compute_id': {'key': 'properties.computeId', 'type': 'str'}, - 'custom_image_id': {'key': 'properties.customImageId', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'size': {'key': 'properties.size', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'ssh_key': {'key': 'properties.sshKey', 'type': 'str'}, - 'is_authentication_with_ssh_key': {'key': 'properties.isAuthenticationWithSshKey', 'type': 'bool'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'lab_subnet_name': {'key': 'properties.labSubnetName', 'type': 'str'}, - 'lab_virtual_network_id': {'key': 'properties.labVirtualNetworkId', 'type': 'str'}, - 'disallow_public_ip_address': {'key': 'properties.disallowPublicIpAddress', 'type': 'bool'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[ArtifactInstallProperties]'}, - 'artifact_deployment_status': {'key': 'properties.artifactDeploymentStatus', 'type': 'ArtifactDeploymentStatusProperties'}, - 'gallery_image_reference': {'key': 'properties.galleryImageReference', 'type': 'GalleryImageReference'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterfaceProperties'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'allow_claim': {'key': 'properties.allowClaim', 'type': 'bool'}, - 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, - 'virtual_machine_creation_source': {'key': 'properties.virtualMachineCreationSource', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - 'data_disk_parameters': {'key': 'properties.dataDiskParameters', 'type': '[DataDiskProperties]'}, - 'schedule_parameters': {'key': 'properties.scheduleParameters', 'type': '[ScheduleCreationParameter]'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabVirtualMachineCreationParameter, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.bulk_creation_parameters = kwargs.get('bulk_creation_parameters', None) - self.notes = kwargs.get('notes', None) - self.owner_object_id = kwargs.get('owner_object_id', None) - self.owner_user_principal_name = kwargs.get('owner_user_principal_name', None) - self.created_by_user_id = kwargs.get('created_by_user_id', None) - self.created_by_user = kwargs.get('created_by_user', None) - self.created_date = kwargs.get('created_date', None) - self.compute_id = kwargs.get('compute_id', None) - self.custom_image_id = kwargs.get('custom_image_id', None) - self.os_type = kwargs.get('os_type', None) - self.size = kwargs.get('size', None) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - self.ssh_key = kwargs.get('ssh_key', None) - self.is_authentication_with_ssh_key = kwargs.get('is_authentication_with_ssh_key', None) - self.fqdn = kwargs.get('fqdn', None) - self.lab_subnet_name = kwargs.get('lab_subnet_name', None) - self.lab_virtual_network_id = kwargs.get('lab_virtual_network_id', None) - self.disallow_public_ip_address = kwargs.get('disallow_public_ip_address', None) - self.artifacts = kwargs.get('artifacts', None) - self.artifact_deployment_status = kwargs.get('artifact_deployment_status', None) - self.gallery_image_reference = kwargs.get('gallery_image_reference', None) - self.plan_id = kwargs.get('plan_id', None) - self.network_interface = kwargs.get('network_interface', None) - self.expiration_date = kwargs.get('expiration_date', None) - self.allow_claim = kwargs.get('allow_claim', None) - self.storage_type = kwargs.get('storage_type', None) - self.virtual_machine_creation_source = kwargs.get('virtual_machine_creation_source', None) - self.environment_id = kwargs.get('environment_id', None) - self.data_disk_parameters = kwargs.get('data_disk_parameters', None) - self.schedule_parameters = kwargs.get('schedule_parameters', None) - self.last_known_power_state = kwargs.get('last_known_power_state', None) - - -class LabVirtualMachineCreationParameterFragment(msrest.serialization.Model): - """Properties for creating a virtual machine. - - :param name: The name of the virtual machine or environment. - :type name: str - :param location: The location of the new virtual machine or environment. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param bulk_creation_parameters: The number of virtual machine instances to create. - :type bulk_creation_parameters: ~azure.mgmt.devtestlabs.models.BulkCreationParametersFragment - :param notes: The notes of the virtual machine. - :type notes: str - :param owner_object_id: The object identifier of the owner of the virtual machine. - :type owner_object_id: str - :param owner_user_principal_name: The user principal name of the virtual machine owner. - :type owner_user_principal_name: str - :param created_by_user_id: The object identifier of the creator of the virtual machine. - :type created_by_user_id: str - :param created_by_user: The email address of creator of the virtual machine. - :type created_by_user: str - :param created_date: The creation date of the virtual machine. - :type created_date: ~datetime.datetime - :param compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. - :type compute_id: str - :param custom_image_id: The custom image identifier of the virtual machine. - :type custom_image_id: str - :param os_type: The OS type of the virtual machine. - :type os_type: str - :param size: The size of the virtual machine. - :type size: str - :param user_name: The user name of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine administrator. - :type password: str - :param ssh_key: The SSH key of the virtual machine administrator. - :type ssh_key: str - :param is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key - for authentication. - :type is_authentication_with_ssh_key: bool - :param fqdn: The fully-qualified domain name of the virtual machine. - :type fqdn: str - :param lab_subnet_name: The lab subnet name of the virtual machine. - :type lab_subnet_name: str - :param lab_virtual_network_id: The lab virtual network identifier of the virtual machine. - :type lab_virtual_network_id: str - :param disallow_public_ip_address: Indicates whether the virtual machine is to be created - without a public IP address. - :type disallow_public_ip_address: bool - :param artifacts: The artifacts to be installed on the virtual machine. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallPropertiesFragment] - :param artifact_deployment_status: The artifact deployment status for the virtual machine. - :type artifact_deployment_status: - ~azure.mgmt.devtestlabs.models.ArtifactDeploymentStatusPropertiesFragment - :param gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual - machine. - :type gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReferenceFragment - :param plan_id: The id of the plan associated with the virtual machine image. - :type plan_id: str - :param network_interface: The network interface properties. - :type network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfacePropertiesFragment - :param expiration_date: The expiration date for VM. - :type expiration_date: ~datetime.datetime - :param allow_claim: Indicates whether another user can take ownership of the virtual machine. - :type allow_claim: bool - :param storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). - :type storage_type: str - :param virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output - property only. Possible values include: "FromCustomImage", "FromGalleryImage", - "FromSharedGalleryImage". - :type virtual_machine_creation_source: str or - ~azure.mgmt.devtestlabs.models.VirtualMachineCreationSource - :param environment_id: The resource ID of the environment that contains this virtual machine, - if any. - :type environment_id: str - :param data_disk_parameters: New or existing data disks to attach to the virtual machine after - creation. - :type data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskPropertiesFragment] - :param schedule_parameters: Virtual Machine schedules to be created. - :type schedule_parameters: - list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameterFragment] - :param last_known_power_state: Last known compute power state captured in DTL. - :type last_known_power_state: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'bulk_creation_parameters': {'key': 'properties.bulkCreationParameters', 'type': 'BulkCreationParametersFragment'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owner_object_id': {'key': 'properties.ownerObjectId', 'type': 'str'}, - 'owner_user_principal_name': {'key': 'properties.ownerUserPrincipalName', 'type': 'str'}, - 'created_by_user_id': {'key': 'properties.createdByUserId', 'type': 'str'}, - 'created_by_user': {'key': 'properties.createdByUser', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'compute_id': {'key': 'properties.computeId', 'type': 'str'}, - 'custom_image_id': {'key': 'properties.customImageId', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'size': {'key': 'properties.size', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'ssh_key': {'key': 'properties.sshKey', 'type': 'str'}, - 'is_authentication_with_ssh_key': {'key': 'properties.isAuthenticationWithSshKey', 'type': 'bool'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'lab_subnet_name': {'key': 'properties.labSubnetName', 'type': 'str'}, - 'lab_virtual_network_id': {'key': 'properties.labVirtualNetworkId', 'type': 'str'}, - 'disallow_public_ip_address': {'key': 'properties.disallowPublicIpAddress', 'type': 'bool'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[ArtifactInstallPropertiesFragment]'}, - 'artifact_deployment_status': {'key': 'properties.artifactDeploymentStatus', 'type': 'ArtifactDeploymentStatusPropertiesFragment'}, - 'gallery_image_reference': {'key': 'properties.galleryImageReference', 'type': 'GalleryImageReferenceFragment'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterfacePropertiesFragment'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'allow_claim': {'key': 'properties.allowClaim', 'type': 'bool'}, - 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, - 'virtual_machine_creation_source': {'key': 'properties.virtualMachineCreationSource', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - 'data_disk_parameters': {'key': 'properties.dataDiskParameters', 'type': '[DataDiskPropertiesFragment]'}, - 'schedule_parameters': {'key': 'properties.scheduleParameters', 'type': '[ScheduleCreationParameterFragment]'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabVirtualMachineCreationParameterFragment, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.bulk_creation_parameters = kwargs.get('bulk_creation_parameters', None) - self.notes = kwargs.get('notes', None) - self.owner_object_id = kwargs.get('owner_object_id', None) - self.owner_user_principal_name = kwargs.get('owner_user_principal_name', None) - self.created_by_user_id = kwargs.get('created_by_user_id', None) - self.created_by_user = kwargs.get('created_by_user', None) - self.created_date = kwargs.get('created_date', None) - self.compute_id = kwargs.get('compute_id', None) - self.custom_image_id = kwargs.get('custom_image_id', None) - self.os_type = kwargs.get('os_type', None) - self.size = kwargs.get('size', None) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - self.ssh_key = kwargs.get('ssh_key', None) - self.is_authentication_with_ssh_key = kwargs.get('is_authentication_with_ssh_key', None) - self.fqdn = kwargs.get('fqdn', None) - self.lab_subnet_name = kwargs.get('lab_subnet_name', None) - self.lab_virtual_network_id = kwargs.get('lab_virtual_network_id', None) - self.disallow_public_ip_address = kwargs.get('disallow_public_ip_address', None) - self.artifacts = kwargs.get('artifacts', None) - self.artifact_deployment_status = kwargs.get('artifact_deployment_status', None) - self.gallery_image_reference = kwargs.get('gallery_image_reference', None) - self.plan_id = kwargs.get('plan_id', None) - self.network_interface = kwargs.get('network_interface', None) - self.expiration_date = kwargs.get('expiration_date', None) - self.allow_claim = kwargs.get('allow_claim', None) - self.storage_type = kwargs.get('storage_type', None) - self.virtual_machine_creation_source = kwargs.get('virtual_machine_creation_source', None) - self.environment_id = kwargs.get('environment_id', None) - self.data_disk_parameters = kwargs.get('data_disk_parameters', None) - self.schedule_parameters = kwargs.get('schedule_parameters', None) - self.last_known_power_state = kwargs.get('last_known_power_state', None) - - -class LabVirtualMachineFragment(UpdateResource): - """A virtual machine. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param notes: The notes of the virtual machine. - :type notes: str - :param owner_object_id: The object identifier of the owner of the virtual machine. - :type owner_object_id: str - :param owner_user_principal_name: The user principal name of the virtual machine owner. - :type owner_user_principal_name: str - :param created_by_user_id: The object identifier of the creator of the virtual machine. - :type created_by_user_id: str - :param created_by_user: The email address of creator of the virtual machine. - :type created_by_user: str - :param created_date: The creation date of the virtual machine. - :type created_date: ~datetime.datetime - :param compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. - :type compute_id: str - :param custom_image_id: The custom image identifier of the virtual machine. - :type custom_image_id: str - :param os_type: The OS type of the virtual machine. - :type os_type: str - :param size: The size of the virtual machine. - :type size: str - :param user_name: The user name of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine administrator. - :type password: str - :param ssh_key: The SSH key of the virtual machine administrator. - :type ssh_key: str - :param is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key - for authentication. - :type is_authentication_with_ssh_key: bool - :param fqdn: The fully-qualified domain name of the virtual machine. - :type fqdn: str - :param lab_subnet_name: The lab subnet name of the virtual machine. - :type lab_subnet_name: str - :param lab_virtual_network_id: The lab virtual network identifier of the virtual machine. - :type lab_virtual_network_id: str - :param disallow_public_ip_address: Indicates whether the virtual machine is to be created - without a public IP address. - :type disallow_public_ip_address: bool - :param artifacts: The artifacts to be installed on the virtual machine. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallPropertiesFragment] - :param artifact_deployment_status: The artifact deployment status for the virtual machine. - :type artifact_deployment_status: - ~azure.mgmt.devtestlabs.models.ArtifactDeploymentStatusPropertiesFragment - :param gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual - machine. - :type gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReferenceFragment - :param plan_id: The id of the plan associated with the virtual machine image. - :type plan_id: str - :param network_interface: The network interface properties. - :type network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfacePropertiesFragment - :param expiration_date: The expiration date for VM. - :type expiration_date: ~datetime.datetime - :param allow_claim: Indicates whether another user can take ownership of the virtual machine. - :type allow_claim: bool - :param storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). - :type storage_type: str - :param virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output - property only. Possible values include: "FromCustomImage", "FromGalleryImage", - "FromSharedGalleryImage". - :type virtual_machine_creation_source: str or - ~azure.mgmt.devtestlabs.models.VirtualMachineCreationSource - :param environment_id: The resource ID of the environment that contains this virtual machine, - if any. - :type environment_id: str - :param data_disk_parameters: New or existing data disks to attach to the virtual machine after - creation. - :type data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskPropertiesFragment] - :param schedule_parameters: Virtual Machine schedules to be created. - :type schedule_parameters: - list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameterFragment] - :param last_known_power_state: Last known compute power state captured in DTL. - :type last_known_power_state: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owner_object_id': {'key': 'properties.ownerObjectId', 'type': 'str'}, - 'owner_user_principal_name': {'key': 'properties.ownerUserPrincipalName', 'type': 'str'}, - 'created_by_user_id': {'key': 'properties.createdByUserId', 'type': 'str'}, - 'created_by_user': {'key': 'properties.createdByUser', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'compute_id': {'key': 'properties.computeId', 'type': 'str'}, - 'custom_image_id': {'key': 'properties.customImageId', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'size': {'key': 'properties.size', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'ssh_key': {'key': 'properties.sshKey', 'type': 'str'}, - 'is_authentication_with_ssh_key': {'key': 'properties.isAuthenticationWithSshKey', 'type': 'bool'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'lab_subnet_name': {'key': 'properties.labSubnetName', 'type': 'str'}, - 'lab_virtual_network_id': {'key': 'properties.labVirtualNetworkId', 'type': 'str'}, - 'disallow_public_ip_address': {'key': 'properties.disallowPublicIpAddress', 'type': 'bool'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[ArtifactInstallPropertiesFragment]'}, - 'artifact_deployment_status': {'key': 'properties.artifactDeploymentStatus', 'type': 'ArtifactDeploymentStatusPropertiesFragment'}, - 'gallery_image_reference': {'key': 'properties.galleryImageReference', 'type': 'GalleryImageReferenceFragment'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterfacePropertiesFragment'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'allow_claim': {'key': 'properties.allowClaim', 'type': 'bool'}, - 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, - 'virtual_machine_creation_source': {'key': 'properties.virtualMachineCreationSource', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - 'data_disk_parameters': {'key': 'properties.dataDiskParameters', 'type': '[DataDiskPropertiesFragment]'}, - 'schedule_parameters': {'key': 'properties.scheduleParameters', 'type': '[ScheduleCreationParameterFragment]'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabVirtualMachineFragment, self).__init__(**kwargs) - self.notes = kwargs.get('notes', None) - self.owner_object_id = kwargs.get('owner_object_id', None) - self.owner_user_principal_name = kwargs.get('owner_user_principal_name', None) - self.created_by_user_id = kwargs.get('created_by_user_id', None) - self.created_by_user = kwargs.get('created_by_user', None) - self.created_date = kwargs.get('created_date', None) - self.compute_id = kwargs.get('compute_id', None) - self.custom_image_id = kwargs.get('custom_image_id', None) - self.os_type = kwargs.get('os_type', None) - self.size = kwargs.get('size', None) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - self.ssh_key = kwargs.get('ssh_key', None) - self.is_authentication_with_ssh_key = kwargs.get('is_authentication_with_ssh_key', None) - self.fqdn = kwargs.get('fqdn', None) - self.lab_subnet_name = kwargs.get('lab_subnet_name', None) - self.lab_virtual_network_id = kwargs.get('lab_virtual_network_id', None) - self.disallow_public_ip_address = kwargs.get('disallow_public_ip_address', None) - self.artifacts = kwargs.get('artifacts', None) - self.artifact_deployment_status = kwargs.get('artifact_deployment_status', None) - self.gallery_image_reference = kwargs.get('gallery_image_reference', None) - self.plan_id = kwargs.get('plan_id', None) - self.network_interface = kwargs.get('network_interface', None) - self.expiration_date = kwargs.get('expiration_date', None) - self.allow_claim = kwargs.get('allow_claim', None) - self.storage_type = kwargs.get('storage_type', None) - self.virtual_machine_creation_source = kwargs.get('virtual_machine_creation_source', None) - self.environment_id = kwargs.get('environment_id', None) - self.data_disk_parameters = kwargs.get('data_disk_parameters', None) - self.schedule_parameters = kwargs.get('schedule_parameters', None) - self.last_known_power_state = kwargs.get('last_known_power_state', None) - - -class LabVirtualMachineList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.LabVirtualMachine] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[LabVirtualMachine]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabVirtualMachineList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class LinuxOsInfo(msrest.serialization.Model): - """Information about a Linux OS. - - :param linux_os_state: The state of the Linux OS (i.e. NonDeprovisioned, DeprovisionRequested, - DeprovisionApplied). Possible values include: "NonDeprovisioned", "DeprovisionRequested", - "DeprovisionApplied". - :type linux_os_state: str or ~azure.mgmt.devtestlabs.models.LinuxOsState - """ - - _attribute_map = { - 'linux_os_state': {'key': 'linuxOsState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LinuxOsInfo, self).__init__(**kwargs) - self.linux_os_state = kwargs.get('linux_os_state', None) - - -class LinuxOsInfoFragment(msrest.serialization.Model): - """Information about a Linux OS. - - :param linux_os_state: The state of the Linux OS (i.e. NonDeprovisioned, DeprovisionRequested, - DeprovisionApplied). Possible values include: "NonDeprovisioned", "DeprovisionRequested", - "DeprovisionApplied". - :type linux_os_state: str or ~azure.mgmt.devtestlabs.models.LinuxOsState - """ - - _attribute_map = { - 'linux_os_state': {'key': 'linuxOsState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LinuxOsInfoFragment, self).__init__(**kwargs) - self.linux_os_state = kwargs.get('linux_os_state', None) - - -class NetworkInterfaceProperties(msrest.serialization.Model): - """Properties of a network interface. - - :param virtual_network_id: The resource ID of the virtual network. - :type virtual_network_id: str - :param subnet_id: The resource ID of the sub net. - :type subnet_id: str - :param public_ip_address_id: The resource ID of the public IP address. - :type public_ip_address_id: str - :param public_ip_address: The public IP address. - :type public_ip_address: str - :param private_ip_address: The private IP address. - :type private_ip_address: str - :param dns_name: The DNS name. - :type dns_name: str - :param rdp_authority: The RdpAuthority property is a server DNS host name or IP address - followed by the service port number for RDP (Remote Desktop Protocol). - :type rdp_authority: str - :param ssh_authority: The SshAuthority property is a server DNS host name or IP address - followed by the service port number for SSH. - :type ssh_authority: str - :param shared_public_ip_address_configuration: The configuration for sharing a public IP - address across multiple virtual machines. - :type shared_public_ip_address_configuration: - ~azure.mgmt.devtestlabs.models.SharedPublicIpAddressConfiguration - """ - - _attribute_map = { - 'virtual_network_id': {'key': 'virtualNetworkId', 'type': 'str'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'public_ip_address_id': {'key': 'publicIpAddressId', 'type': 'str'}, - 'public_ip_address': {'key': 'publicIpAddress', 'type': 'str'}, - 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, - 'dns_name': {'key': 'dnsName', 'type': 'str'}, - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, - 'shared_public_ip_address_configuration': {'key': 'sharedPublicIpAddressConfiguration', 'type': 'SharedPublicIpAddressConfiguration'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkInterfaceProperties, self).__init__(**kwargs) - self.virtual_network_id = kwargs.get('virtual_network_id', None) - self.subnet_id = kwargs.get('subnet_id', None) - self.public_ip_address_id = kwargs.get('public_ip_address_id', None) - self.public_ip_address = kwargs.get('public_ip_address', None) - self.private_ip_address = kwargs.get('private_ip_address', None) - self.dns_name = kwargs.get('dns_name', None) - self.rdp_authority = kwargs.get('rdp_authority', None) - self.ssh_authority = kwargs.get('ssh_authority', None) - self.shared_public_ip_address_configuration = kwargs.get('shared_public_ip_address_configuration', None) - - -class NetworkInterfacePropertiesFragment(msrest.serialization.Model): - """Properties of a network interface. - - :param virtual_network_id: The resource ID of the virtual network. - :type virtual_network_id: str - :param subnet_id: The resource ID of the sub net. - :type subnet_id: str - :param public_ip_address_id: The resource ID of the public IP address. - :type public_ip_address_id: str - :param public_ip_address: The public IP address. - :type public_ip_address: str - :param private_ip_address: The private IP address. - :type private_ip_address: str - :param dns_name: The DNS name. - :type dns_name: str - :param rdp_authority: The RdpAuthority property is a server DNS host name or IP address - followed by the service port number for RDP (Remote Desktop Protocol). - :type rdp_authority: str - :param ssh_authority: The SshAuthority property is a server DNS host name or IP address - followed by the service port number for SSH. - :type ssh_authority: str - :param shared_public_ip_address_configuration: The configuration for sharing a public IP - address across multiple virtual machines. - :type shared_public_ip_address_configuration: - ~azure.mgmt.devtestlabs.models.SharedPublicIpAddressConfigurationFragment - """ - - _attribute_map = { - 'virtual_network_id': {'key': 'virtualNetworkId', 'type': 'str'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'public_ip_address_id': {'key': 'publicIpAddressId', 'type': 'str'}, - 'public_ip_address': {'key': 'publicIpAddress', 'type': 'str'}, - 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, - 'dns_name': {'key': 'dnsName', 'type': 'str'}, - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, - 'shared_public_ip_address_configuration': {'key': 'sharedPublicIpAddressConfiguration', 'type': 'SharedPublicIpAddressConfigurationFragment'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkInterfacePropertiesFragment, self).__init__(**kwargs) - self.virtual_network_id = kwargs.get('virtual_network_id', None) - self.subnet_id = kwargs.get('subnet_id', None) - self.public_ip_address_id = kwargs.get('public_ip_address_id', None) - self.public_ip_address = kwargs.get('public_ip_address', None) - self.private_ip_address = kwargs.get('private_ip_address', None) - self.dns_name = kwargs.get('dns_name', None) - self.rdp_authority = kwargs.get('rdp_authority', None) - self.ssh_authority = kwargs.get('ssh_authority', None) - self.shared_public_ip_address_configuration = kwargs.get('shared_public_ip_address_configuration', None) - - -class NotificationChannel(Resource): - """A notification. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param web_hook_url: The webhook URL to send notifications to. - :type web_hook_url: str - :param email_recipient: The email recipient to send notifications to (can be a list of semi- - colon separated email addresses). - :type email_recipient: str - :param notification_locale: The locale to use when sending a notification (fallback for - unsupported languages is EN). - :type notification_locale: str - :param description: Description of notification. - :type description: str - :param events: The list of event for which this notification is enabled. - :type events: list[~azure.mgmt.devtestlabs.models.Event] - :ivar created_date: The creation date of the notification channel. - :vartype created_date: ~datetime.datetime - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'web_hook_url': {'key': 'properties.webHookUrl', 'type': 'str'}, - 'email_recipient': {'key': 'properties.emailRecipient', 'type': 'str'}, - 'notification_locale': {'key': 'properties.notificationLocale', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'events': {'key': 'properties.events', 'type': '[Event]'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NotificationChannel, self).__init__(**kwargs) - self.web_hook_url = kwargs.get('web_hook_url', None) - self.email_recipient = kwargs.get('email_recipient', None) - self.notification_locale = kwargs.get('notification_locale', None) - self.description = kwargs.get('description', None) - self.events = kwargs.get('events', None) - self.created_date = None - self.provisioning_state = None - self.unique_identifier = None - - -class NotificationChannelFragment(UpdateResource): - """A notification. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param web_hook_url: The webhook URL to send notifications to. - :type web_hook_url: str - :param email_recipient: The email recipient to send notifications to (can be a list of semi- - colon separated email addresses). - :type email_recipient: str - :param notification_locale: The locale to use when sending a notification (fallback for - unsupported languages is EN). - :type notification_locale: str - :param description: Description of notification. - :type description: str - :param events: The list of event for which this notification is enabled. - :type events: list[~azure.mgmt.devtestlabs.models.EventFragment] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'web_hook_url': {'key': 'properties.webHookUrl', 'type': 'str'}, - 'email_recipient': {'key': 'properties.emailRecipient', 'type': 'str'}, - 'notification_locale': {'key': 'properties.notificationLocale', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'events': {'key': 'properties.events', 'type': '[EventFragment]'}, - } - - def __init__( - self, - **kwargs - ): - super(NotificationChannelFragment, self).__init__(**kwargs) - self.web_hook_url = kwargs.get('web_hook_url', None) - self.email_recipient = kwargs.get('email_recipient', None) - self.notification_locale = kwargs.get('notification_locale', None) - self.description = kwargs.get('description', None) - self.events = kwargs.get('events', None) - - -class NotificationChannelList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.NotificationChannel] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NotificationChannel]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NotificationChannelList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class NotificationSettings(msrest.serialization.Model): - """Notification settings for a schedule. - - :param status: If notifications are enabled for this schedule (i.e. Enabled, Disabled). - Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param time_in_minutes: Time in minutes before event at which notification will be sent. - :type time_in_minutes: int - :param webhook_url: The webhook URL to which the notification will be sent. - :type webhook_url: str - :param email_recipient: The email recipient to send notifications to (can be a list of semi- - colon separated email addresses). - :type email_recipient: str - :param notification_locale: The locale to use when sending a notification (fallback for - unsupported languages is EN). - :type notification_locale: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'time_in_minutes': {'key': 'timeInMinutes', 'type': 'int'}, - 'webhook_url': {'key': 'webhookUrl', 'type': 'str'}, - 'email_recipient': {'key': 'emailRecipient', 'type': 'str'}, - 'notification_locale': {'key': 'notificationLocale', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NotificationSettings, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.time_in_minutes = kwargs.get('time_in_minutes', None) - self.webhook_url = kwargs.get('webhook_url', None) - self.email_recipient = kwargs.get('email_recipient', None) - self.notification_locale = kwargs.get('notification_locale', None) - - -class NotificationSettingsFragment(msrest.serialization.Model): - """Notification settings for a schedule. - - :param status: If notifications are enabled for this schedule (i.e. Enabled, Disabled). - Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param time_in_minutes: Time in minutes before event at which notification will be sent. - :type time_in_minutes: int - :param webhook_url: The webhook URL to which the notification will be sent. - :type webhook_url: str - :param email_recipient: The email recipient to send notifications to (can be a list of semi- - colon separated email addresses). - :type email_recipient: str - :param notification_locale: The locale to use when sending a notification (fallback for - unsupported languages is EN). - :type notification_locale: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'time_in_minutes': {'key': 'timeInMinutes', 'type': 'int'}, - 'webhook_url': {'key': 'webhookUrl', 'type': 'str'}, - 'email_recipient': {'key': 'emailRecipient', 'type': 'str'}, - 'notification_locale': {'key': 'notificationLocale', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NotificationSettingsFragment, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.time_in_minutes = kwargs.get('time_in_minutes', None) - self.webhook_url = kwargs.get('webhook_url', None) - self.email_recipient = kwargs.get('email_recipient', None) - self.notification_locale = kwargs.get('notification_locale', None) - - -class NotifyParameters(msrest.serialization.Model): - """Properties for generating a Notification. - - :param event_name: The type of event (i.e. AutoShutdown, Cost). Possible values include: - "AutoShutdown", "Cost". - :type event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType - :param json_payload: Properties for the notification in json format. - :type json_payload: str - """ - - _attribute_map = { - 'event_name': {'key': 'eventName', 'type': 'str'}, - 'json_payload': {'key': 'jsonPayload', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NotifyParameters, self).__init__(**kwargs) - self.event_name = kwargs.get('event_name', None) - self.json_payload = kwargs.get('json_payload', None) - - -class OperationError(msrest.serialization.Model): - """Error details for the operation in case of a failure. - - :param code: The error code of the operation error. - :type code: str - :param message: The error message of the operation error. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class OperationMetadata(msrest.serialization.Model): - """The REST API operation supported by DevTestLab ResourceProvider. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that describes the operations. - :type display: ~azure.mgmt.devtestlabs.models.OperationMetadataDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationMetadataDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationMetadata, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationMetadataDisplay(msrest.serialization.Model): - """The object that describes the operations. - - :param provider: Friendly name of the resource provider. - :type provider: str - :param resource: Resource type on which the operation is performed. - :type resource: str - :param operation: Operation type: read, write, delete, listKeys/action, etc. - :type operation: str - :param description: Friendly name of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationMetadataDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationResult(msrest.serialization.Model): - """An Operation Result. - - :param status: The operation status. - :type status: str - :param status_code: The status code for the operation. Possible values include: "Continue", - "SwitchingProtocols", "OK", "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", - "ResetContent", "PartialContent", "MultipleChoices", "MovedPermanently", "Redirect", - "SeeOther", "NotModified", "UseProxy", "Unused", "TemporaryRedirect", "BadRequest", - "Unauthorized", "PaymentRequired", "Forbidden", "NotFound", "MethodNotAllowed", - "NotAcceptable", "ProxyAuthenticationRequired", "RequestTimeout", "Conflict", "Gone", - "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", - "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", - "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", - "HttpVersionNotSupported". - :type status_code: str or ~azure.mgmt.devtestlabs.models.HttpStatusCode - :param error: Error details for the operation in case of a failure. - :type error: ~azure.mgmt.devtestlabs.models.OperationError - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'OperationError'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResult, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.status_code = kwargs.get('status_code', None) - self.error = kwargs.get('error', None) - - -class ParameterInfo(msrest.serialization.Model): - """Information about an artifact's parameter. - - :param name: The name of the artifact parameter. - :type name: str - :param value: The value of the artifact parameter. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ParameterInfo, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class ParametersValueFileInfo(msrest.serialization.Model): - """A file containing a set of parameter values for an ARM template. - - :param file_name: File name. - :type file_name: str - :param parameters_value_info: Contents of the file. - :type parameters_value_info: object - """ - - _attribute_map = { - 'file_name': {'key': 'fileName', 'type': 'str'}, - 'parameters_value_info': {'key': 'parametersValueInfo', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ParametersValueFileInfo, self).__init__(**kwargs) - self.file_name = kwargs.get('file_name', None) - self.parameters_value_info = kwargs.get('parameters_value_info', None) - - -class PercentageCostThresholdProperties(msrest.serialization.Model): - """Properties of a percentage cost threshold. - - :param threshold_value: The cost threshold value. - :type threshold_value: float - """ - - _attribute_map = { - 'threshold_value': {'key': 'thresholdValue', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(PercentageCostThresholdProperties, self).__init__(**kwargs) - self.threshold_value = kwargs.get('threshold_value', None) - - -class Policy(Resource): - """A Policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param description: The description of the policy. - :type description: str - :param status: The status of the policy. Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.PolicyStatus - :param fact_name: The fact name of the policy (e.g. LabVmCount, LabVmSize, MaxVmsAllowedPerLab, - etc. Possible values include: "UserOwnedLabVmCount", "UserOwnedLabPremiumVmCount", - "LabVmCount", "LabPremiumVmCount", "LabVmSize", "GalleryImage", "UserOwnedLabVmCountInSubnet", - "LabTargetCost", "EnvironmentTemplate", "ScheduleEditPermission". - :type fact_name: str or ~azure.mgmt.devtestlabs.models.PolicyFactName - :param fact_data: The fact data of the policy. - :type fact_data: str - :param threshold: The threshold of the policy (i.e. a number for MaxValuePolicy, and a JSON - array of values for AllowedValuesPolicy). - :type threshold: str - :param evaluator_type: The evaluator type of the policy (i.e. AllowedValuesPolicy, - MaxValuePolicy). Possible values include: "AllowedValuesPolicy", "MaxValuePolicy". - :type evaluator_type: str or ~azure.mgmt.devtestlabs.models.PolicyEvaluatorType - :ivar created_date: The creation date of the policy. - :vartype created_date: ~datetime.datetime - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'fact_name': {'key': 'properties.factName', 'type': 'str'}, - 'fact_data': {'key': 'properties.factData', 'type': 'str'}, - 'threshold': {'key': 'properties.threshold', 'type': 'str'}, - 'evaluator_type': {'key': 'properties.evaluatorType', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Policy, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.status = kwargs.get('status', None) - self.fact_name = kwargs.get('fact_name', None) - self.fact_data = kwargs.get('fact_data', None) - self.threshold = kwargs.get('threshold', None) - self.evaluator_type = kwargs.get('evaluator_type', None) - self.created_date = None - self.provisioning_state = None - self.unique_identifier = None - - -class PolicyFragment(UpdateResource): - """A Policy. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param description: The description of the policy. - :type description: str - :param status: The status of the policy. Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.PolicyStatus - :param fact_name: The fact name of the policy (e.g. LabVmCount, LabVmSize, MaxVmsAllowedPerLab, - etc. Possible values include: "UserOwnedLabVmCount", "UserOwnedLabPremiumVmCount", - "LabVmCount", "LabPremiumVmCount", "LabVmSize", "GalleryImage", "UserOwnedLabVmCountInSubnet", - "LabTargetCost", "EnvironmentTemplate", "ScheduleEditPermission". - :type fact_name: str or ~azure.mgmt.devtestlabs.models.PolicyFactName - :param fact_data: The fact data of the policy. - :type fact_data: str - :param threshold: The threshold of the policy (i.e. a number for MaxValuePolicy, and a JSON - array of values for AllowedValuesPolicy). - :type threshold: str - :param evaluator_type: The evaluator type of the policy (i.e. AllowedValuesPolicy, - MaxValuePolicy). Possible values include: "AllowedValuesPolicy", "MaxValuePolicy". - :type evaluator_type: str or ~azure.mgmt.devtestlabs.models.PolicyEvaluatorType - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'fact_name': {'key': 'properties.factName', 'type': 'str'}, - 'fact_data': {'key': 'properties.factData', 'type': 'str'}, - 'threshold': {'key': 'properties.threshold', 'type': 'str'}, - 'evaluator_type': {'key': 'properties.evaluatorType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyFragment, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.status = kwargs.get('status', None) - self.fact_name = kwargs.get('fact_name', None) - self.fact_data = kwargs.get('fact_data', None) - self.threshold = kwargs.get('threshold', None) - self.evaluator_type = kwargs.get('evaluator_type', None) - - -class PolicyList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Policy] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Policy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PolicySetResult(msrest.serialization.Model): - """Result of a policy set evaluation. - - :param has_error: A value indicating whether this policy set evaluation has discovered - violations. - :type has_error: bool - :param policy_violations: The list of policy violations. - :type policy_violations: list[~azure.mgmt.devtestlabs.models.PolicyViolation] - """ - - _attribute_map = { - 'has_error': {'key': 'hasError', 'type': 'bool'}, - 'policy_violations': {'key': 'policyViolations', 'type': '[PolicyViolation]'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicySetResult, self).__init__(**kwargs) - self.has_error = kwargs.get('has_error', None) - self.policy_violations = kwargs.get('policy_violations', None) - - -class PolicyViolation(msrest.serialization.Model): - """Policy violation. - - :param code: The code of the policy violation. - :type code: str - :param message: The message of the policy violation. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyViolation, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class Port(msrest.serialization.Model): - """Properties of a network port. - - :param transport_protocol: Protocol type of the port. Possible values include: "Tcp", "Udp". - :type transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol - :param backend_port: Backend port of the target virtual machine. - :type backend_port: int - """ - - _attribute_map = { - 'transport_protocol': {'key': 'transportProtocol', 'type': 'str'}, - 'backend_port': {'key': 'backendPort', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Port, self).__init__(**kwargs) - self.transport_protocol = kwargs.get('transport_protocol', None) - self.backend_port = kwargs.get('backend_port', None) - - -class PortFragment(msrest.serialization.Model): - """Properties of a network port. - - :param transport_protocol: Protocol type of the port. Possible values include: "Tcp", "Udp". - :type transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol - :param backend_port: Backend port of the target virtual machine. - :type backend_port: int - """ - - _attribute_map = { - 'transport_protocol': {'key': 'transportProtocol', 'type': 'str'}, - 'backend_port': {'key': 'backendPort', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(PortFragment, self).__init__(**kwargs) - self.transport_protocol = kwargs.get('transport_protocol', None) - self.backend_port = kwargs.get('backend_port', None) - - -class ProviderOperationResult(msrest.serialization.Model): - """Result of the request to list REST API operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of operations supported by the resource provider. - :type value: list[~azure.mgmt.devtestlabs.models.OperationMetadata] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationMetadata]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperationResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RdpConnection(msrest.serialization.Model): - """Represents a .rdp file. - - :param contents: The contents of the .rdp file. - :type contents: str - """ - - _attribute_map = { - 'contents': {'key': 'contents', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RdpConnection, self).__init__(**kwargs) - self.contents = kwargs.get('contents', None) - - -class ResizeLabVirtualMachineProperties(msrest.serialization.Model): - """Request body for resizing a virtual machine. - - :param size: Specifies the size of the virtual machine. - :type size: str - """ - - _attribute_map = { - 'size': {'key': 'size', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResizeLabVirtualMachineProperties, self).__init__(**kwargs) - self.size = kwargs.get('size', None) - - -class RetargetScheduleProperties(msrest.serialization.Model): - """Properties for retargeting a virtual machine schedule. - - :param current_resource_id: The resource Id of the virtual machine on which the schedule - operates. - :type current_resource_id: str - :param target_resource_id: The resource Id of the virtual machine that the schedule should be - retargeted to. - :type target_resource_id: str - """ - - _attribute_map = { - 'current_resource_id': {'key': 'currentResourceId', 'type': 'str'}, - 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RetargetScheduleProperties, self).__init__(**kwargs) - self.current_resource_id = kwargs.get('current_resource_id', None) - self.target_resource_id = kwargs.get('target_resource_id', None) - - -class Schedule(Resource): - """A schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: - "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). - :type task_type: str - :param weekly_recurrence: If the schedule will occur only some days of the week, specify the - weekly recurrence. - :type weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetails - :param daily_recurrence: If the schedule will occur once each day of the week, specify the - daily recurrence. - :type daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetails - :param hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly - recurrence. - :type hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetails - :param time_zone_id: The time zone ID (e.g. Pacific Standard time). - :type time_zone_id: str - :param notification_settings: Notification settings. - :type notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettings - :ivar created_date: The creation date of the schedule. - :vartype created_date: ~datetime.datetime - :param target_resource_id: The resource ID to which the schedule belongs. - :type target_resource_id: str - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'task_type': {'key': 'properties.taskType', 'type': 'str'}, - 'weekly_recurrence': {'key': 'properties.weeklyRecurrence', 'type': 'WeekDetails'}, - 'daily_recurrence': {'key': 'properties.dailyRecurrence', 'type': 'DayDetails'}, - 'hourly_recurrence': {'key': 'properties.hourlyRecurrence', 'type': 'HourDetails'}, - 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, - 'notification_settings': {'key': 'properties.notificationSettings', 'type': 'NotificationSettings'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Schedule, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.task_type = kwargs.get('task_type', None) - self.weekly_recurrence = kwargs.get('weekly_recurrence', None) - self.daily_recurrence = kwargs.get('daily_recurrence', None) - self.hourly_recurrence = kwargs.get('hourly_recurrence', None) - self.time_zone_id = kwargs.get('time_zone_id', None) - self.notification_settings = kwargs.get('notification_settings', None) - self.created_date = None - self.target_resource_id = kwargs.get('target_resource_id', None) - self.provisioning_state = None - self.unique_identifier = None - - -class ScheduleCreationParameter(msrest.serialization.Model): - """Properties for creating a schedule. - - :param name: The name of the virtual machine or environment. - :type name: str - :param location: The location of the new virtual machine or environment. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: - "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). - :type task_type: str - :param weekly_recurrence: If the schedule will occur only some days of the week, specify the - weekly recurrence. - :type weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetails - :param daily_recurrence: If the schedule will occur once each day of the week, specify the - daily recurrence. - :type daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetails - :param hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly - recurrence. - :type hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetails - :param time_zone_id: The time zone ID (e.g. Pacific Standard time). - :type time_zone_id: str - :param notification_settings: Notification settings. - :type notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettings - :param target_resource_id: The resource ID to which the schedule belongs. - :type target_resource_id: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'task_type': {'key': 'properties.taskType', 'type': 'str'}, - 'weekly_recurrence': {'key': 'properties.weeklyRecurrence', 'type': 'WeekDetails'}, - 'daily_recurrence': {'key': 'properties.dailyRecurrence', 'type': 'DayDetails'}, - 'hourly_recurrence': {'key': 'properties.hourlyRecurrence', 'type': 'HourDetails'}, - 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, - 'notification_settings': {'key': 'properties.notificationSettings', 'type': 'NotificationSettings'}, - 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleCreationParameter, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.status = kwargs.get('status', None) - self.task_type = kwargs.get('task_type', None) - self.weekly_recurrence = kwargs.get('weekly_recurrence', None) - self.daily_recurrence = kwargs.get('daily_recurrence', None) - self.hourly_recurrence = kwargs.get('hourly_recurrence', None) - self.time_zone_id = kwargs.get('time_zone_id', None) - self.notification_settings = kwargs.get('notification_settings', None) - self.target_resource_id = kwargs.get('target_resource_id', None) - - -class ScheduleCreationParameterFragment(msrest.serialization.Model): - """Properties for creating a schedule. - - :param name: The name of the virtual machine or environment. - :type name: str - :param location: The location of the new virtual machine or environment. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: - "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). - :type task_type: str - :param weekly_recurrence: If the schedule will occur only some days of the week, specify the - weekly recurrence. - :type weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetailsFragment - :param daily_recurrence: If the schedule will occur once each day of the week, specify the - daily recurrence. - :type daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetailsFragment - :param hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly - recurrence. - :type hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetailsFragment - :param time_zone_id: The time zone ID (e.g. Pacific Standard time). - :type time_zone_id: str - :param notification_settings: Notification settings. - :type notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettingsFragment - :param target_resource_id: The resource ID to which the schedule belongs. - :type target_resource_id: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'task_type': {'key': 'properties.taskType', 'type': 'str'}, - 'weekly_recurrence': {'key': 'properties.weeklyRecurrence', 'type': 'WeekDetailsFragment'}, - 'daily_recurrence': {'key': 'properties.dailyRecurrence', 'type': 'DayDetailsFragment'}, - 'hourly_recurrence': {'key': 'properties.hourlyRecurrence', 'type': 'HourDetailsFragment'}, - 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, - 'notification_settings': {'key': 'properties.notificationSettings', 'type': 'NotificationSettingsFragment'}, - 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleCreationParameterFragment, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.status = kwargs.get('status', None) - self.task_type = kwargs.get('task_type', None) - self.weekly_recurrence = kwargs.get('weekly_recurrence', None) - self.daily_recurrence = kwargs.get('daily_recurrence', None) - self.hourly_recurrence = kwargs.get('hourly_recurrence', None) - self.time_zone_id = kwargs.get('time_zone_id', None) - self.notification_settings = kwargs.get('notification_settings', None) - self.target_resource_id = kwargs.get('target_resource_id', None) - - -class ScheduleFragment(UpdateResource): - """A schedule. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: - "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). - :type task_type: str - :param weekly_recurrence: If the schedule will occur only some days of the week, specify the - weekly recurrence. - :type weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetailsFragment - :param daily_recurrence: If the schedule will occur once each day of the week, specify the - daily recurrence. - :type daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetailsFragment - :param hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly - recurrence. - :type hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetailsFragment - :param time_zone_id: The time zone ID (e.g. Pacific Standard time). - :type time_zone_id: str - :param notification_settings: Notification settings. - :type notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettingsFragment - :param target_resource_id: The resource ID to which the schedule belongs. - :type target_resource_id: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'task_type': {'key': 'properties.taskType', 'type': 'str'}, - 'weekly_recurrence': {'key': 'properties.weeklyRecurrence', 'type': 'WeekDetailsFragment'}, - 'daily_recurrence': {'key': 'properties.dailyRecurrence', 'type': 'DayDetailsFragment'}, - 'hourly_recurrence': {'key': 'properties.hourlyRecurrence', 'type': 'HourDetailsFragment'}, - 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, - 'notification_settings': {'key': 'properties.notificationSettings', 'type': 'NotificationSettingsFragment'}, - 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleFragment, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.task_type = kwargs.get('task_type', None) - self.weekly_recurrence = kwargs.get('weekly_recurrence', None) - self.daily_recurrence = kwargs.get('daily_recurrence', None) - self.hourly_recurrence = kwargs.get('hourly_recurrence', None) - self.time_zone_id = kwargs.get('time_zone_id', None) - self.notification_settings = kwargs.get('notification_settings', None) - self.target_resource_id = kwargs.get('target_resource_id', None) - - -class ScheduleList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Schedule] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Schedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Secret(Resource): - """A secret. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param value: The value of the secret for secret creation. - :type value: str - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Secret, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.provisioning_state = None - self.unique_identifier = None - - -class SecretFragment(UpdateResource): - """A secret. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param value: The value of the secret for secret creation. - :type value: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SecretFragment, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SecretList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Secret] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Secret]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SecretList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ServiceFabric(Resource): - """A Service Fabric. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param external_service_fabric_id: The backing service fabric resource's id. - :type external_service_fabric_id: str - :param environment_id: The resource id of the environment under which the service fabric - resource is present. - :type environment_id: str - :ivar applicable_schedule: The applicable schedule for the virtual machine. - :vartype applicable_schedule: ~azure.mgmt.devtestlabs.models.ApplicableSchedule - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'applicable_schedule': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'external_service_fabric_id': {'key': 'properties.externalServiceFabricId', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - 'applicable_schedule': {'key': 'properties.applicableSchedule', 'type': 'ApplicableSchedule'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceFabric, self).__init__(**kwargs) - self.external_service_fabric_id = kwargs.get('external_service_fabric_id', None) - self.environment_id = kwargs.get('environment_id', None) - self.applicable_schedule = None - self.provisioning_state = None - self.unique_identifier = None - - -class ServiceFabricFragment(UpdateResource): - """A Service Fabric. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param external_service_fabric_id: The backing service fabric resource's id. - :type external_service_fabric_id: str - :param environment_id: The resource id of the environment under which the service fabric - resource is present. - :type environment_id: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'external_service_fabric_id': {'key': 'properties.externalServiceFabricId', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceFabricFragment, self).__init__(**kwargs) - self.external_service_fabric_id = kwargs.get('external_service_fabric_id', None) - self.environment_id = kwargs.get('environment_id', None) - - -class ServiceFabricList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.ServiceFabric] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceFabric]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceFabricList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ServiceRunner(Resource): - """A container for a managed identity to execute DevTest lab services. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.devtestlabs.models.IdentityProperties - """ - - _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceRunner, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - - -class SharedPublicIpAddressConfiguration(msrest.serialization.Model): - """Properties of a virtual machine that determine how it is connected to a load balancer. - - :param inbound_nat_rules: The incoming NAT rules. - :type inbound_nat_rules: list[~azure.mgmt.devtestlabs.models.InboundNatRule] - """ - - _attribute_map = { - 'inbound_nat_rules': {'key': 'inboundNatRules', 'type': '[InboundNatRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(SharedPublicIpAddressConfiguration, self).__init__(**kwargs) - self.inbound_nat_rules = kwargs.get('inbound_nat_rules', None) - - -class SharedPublicIpAddressConfigurationFragment(msrest.serialization.Model): - """Properties of a virtual machine that determine how it is connected to a load balancer. - - :param inbound_nat_rules: The incoming NAT rules. - :type inbound_nat_rules: list[~azure.mgmt.devtestlabs.models.InboundNatRuleFragment] - """ - - _attribute_map = { - 'inbound_nat_rules': {'key': 'inboundNatRules', 'type': '[InboundNatRuleFragment]'}, - } - - def __init__( - self, - **kwargs - ): - super(SharedPublicIpAddressConfigurationFragment, self).__init__(**kwargs) - self.inbound_nat_rules = kwargs.get('inbound_nat_rules', None) - - -class ShutdownNotificationContent(msrest.serialization.Model): - """The contents of a shutdown notification. Webhooks can use this type to deserialize the request body when they get notified of an imminent shutdown. - - :param skip_url: The URL to skip auto-shutdown. - :type skip_url: str - :param delay_url60: The URL to delay shutdown by 60 minutes. - :type delay_url60: str - :param delay_url120: The URL to delay shutdown by 2 hours. - :type delay_url120: str - :param vm_name: The virtual machine to be shut down. - :type vm_name: str - :param guid: The GUID for the virtual machine to be shut down. - :type guid: str - :param owner: The owner of the virtual machine. - :type owner: str - :param vm_url: The URL of the virtual machine. - :type vm_url: str - :param minutes_until_shutdown: Minutes remaining until shutdown. - :type minutes_until_shutdown: str - :param event_type: The event for which a notification will be sent. - :type event_type: str - :param text: The text for the notification. - :type text: str - :param subscription_id: The subscription ID for the schedule. - :type subscription_id: str - :param resource_group_name: The resource group name for the schedule. - :type resource_group_name: str - :param lab_name: The lab for the schedule. - :type lab_name: str - """ - - _attribute_map = { - 'skip_url': {'key': 'skipUrl', 'type': 'str'}, - 'delay_url60': {'key': 'delayUrl60', 'type': 'str'}, - 'delay_url120': {'key': 'delayUrl120', 'type': 'str'}, - 'vm_name': {'key': 'vmName', 'type': 'str'}, - 'guid': {'key': 'guid', 'type': 'str'}, - 'owner': {'key': 'owner', 'type': 'str'}, - 'vm_url': {'key': 'vmUrl', 'type': 'str'}, - 'minutes_until_shutdown': {'key': 'minutesUntilShutdown', 'type': 'str'}, - 'event_type': {'key': 'eventType', 'type': 'str'}, - 'text': {'key': 'text', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'lab_name': {'key': 'labName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShutdownNotificationContent, self).__init__(**kwargs) - self.skip_url = kwargs.get('skip_url', None) - self.delay_url60 = kwargs.get('delay_url60', None) - self.delay_url120 = kwargs.get('delay_url120', None) - self.vm_name = kwargs.get('vm_name', None) - self.guid = kwargs.get('guid', None) - self.owner = kwargs.get('owner', None) - self.vm_url = kwargs.get('vm_url', None) - self.minutes_until_shutdown = kwargs.get('minutes_until_shutdown', None) - self.event_type = kwargs.get('event_type', None) - self.text = kwargs.get('text', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group_name = kwargs.get('resource_group_name', None) - self.lab_name = kwargs.get('lab_name', None) - - -class Subnet(msrest.serialization.Model): - """Subnet information. - - :param resource_id: The resource ID of the subnet. - :type resource_id: str - :param lab_subnet_name: The name of the subnet as seen in the lab. - :type lab_subnet_name: str - :param allow_public_ip: The permission policy of the subnet for allowing public IP addresses - (i.e. Allow, Deny)). Possible values include: "Default", "Deny", "Allow". - :type allow_public_ip: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'lab_subnet_name': {'key': 'labSubnetName', 'type': 'str'}, - 'allow_public_ip': {'key': 'allowPublicIp', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Subnet, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.lab_subnet_name = kwargs.get('lab_subnet_name', None) - self.allow_public_ip = kwargs.get('allow_public_ip', None) - - -class SubnetFragment(msrest.serialization.Model): - """Subnet information. - - :param resource_id: The resource ID of the subnet. - :type resource_id: str - :param lab_subnet_name: The name of the subnet as seen in the lab. - :type lab_subnet_name: str - :param allow_public_ip: The permission policy of the subnet for allowing public IP addresses - (i.e. Allow, Deny)). Possible values include: "Default", "Deny", "Allow". - :type allow_public_ip: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'lab_subnet_name': {'key': 'labSubnetName', 'type': 'str'}, - 'allow_public_ip': {'key': 'allowPublicIp', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubnetFragment, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.lab_subnet_name = kwargs.get('lab_subnet_name', None) - self.allow_public_ip = kwargs.get('allow_public_ip', None) - - -class SubnetOverride(msrest.serialization.Model): - """Property overrides on a subnet of a virtual network. - - :param resource_id: The resource ID of the subnet. - :type resource_id: str - :param lab_subnet_name: The name given to the subnet within the lab. - :type lab_subnet_name: str - :param use_in_vm_creation_permission: Indicates whether this subnet can be used during virtual - machine creation (i.e. Allow, Deny). Possible values include: "Default", "Deny", "Allow". - :type use_in_vm_creation_permission: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType - :param use_public_ip_address_permission: Indicates whether public IP addresses can be assigned - to virtual machines on this subnet (i.e. Allow, Deny). Possible values include: "Default", - "Deny", "Allow". - :type use_public_ip_address_permission: str or - ~azure.mgmt.devtestlabs.models.UsagePermissionType - :param shared_public_ip_address_configuration: Properties that virtual machines on this subnet - will share. - :type shared_public_ip_address_configuration: - ~azure.mgmt.devtestlabs.models.SubnetSharedPublicIpAddressConfiguration - :param virtual_network_pool_name: The virtual network pool associated with this subnet. - :type virtual_network_pool_name: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'lab_subnet_name': {'key': 'labSubnetName', 'type': 'str'}, - 'use_in_vm_creation_permission': {'key': 'useInVmCreationPermission', 'type': 'str'}, - 'use_public_ip_address_permission': {'key': 'usePublicIpAddressPermission', 'type': 'str'}, - 'shared_public_ip_address_configuration': {'key': 'sharedPublicIpAddressConfiguration', 'type': 'SubnetSharedPublicIpAddressConfiguration'}, - 'virtual_network_pool_name': {'key': 'virtualNetworkPoolName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubnetOverride, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.lab_subnet_name = kwargs.get('lab_subnet_name', None) - self.use_in_vm_creation_permission = kwargs.get('use_in_vm_creation_permission', None) - self.use_public_ip_address_permission = kwargs.get('use_public_ip_address_permission', None) - self.shared_public_ip_address_configuration = kwargs.get('shared_public_ip_address_configuration', None) - self.virtual_network_pool_name = kwargs.get('virtual_network_pool_name', None) - - -class SubnetOverrideFragment(msrest.serialization.Model): - """Property overrides on a subnet of a virtual network. - - :param resource_id: The resource ID of the subnet. - :type resource_id: str - :param lab_subnet_name: The name given to the subnet within the lab. - :type lab_subnet_name: str - :param use_in_vm_creation_permission: Indicates whether this subnet can be used during virtual - machine creation (i.e. Allow, Deny). Possible values include: "Default", "Deny", "Allow". - :type use_in_vm_creation_permission: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType - :param use_public_ip_address_permission: Indicates whether public IP addresses can be assigned - to virtual machines on this subnet (i.e. Allow, Deny). Possible values include: "Default", - "Deny", "Allow". - :type use_public_ip_address_permission: str or - ~azure.mgmt.devtestlabs.models.UsagePermissionType - :param shared_public_ip_address_configuration: Properties that virtual machines on this subnet - will share. - :type shared_public_ip_address_configuration: - ~azure.mgmt.devtestlabs.models.SubnetSharedPublicIpAddressConfigurationFragment - :param virtual_network_pool_name: The virtual network pool associated with this subnet. - :type virtual_network_pool_name: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'lab_subnet_name': {'key': 'labSubnetName', 'type': 'str'}, - 'use_in_vm_creation_permission': {'key': 'useInVmCreationPermission', 'type': 'str'}, - 'use_public_ip_address_permission': {'key': 'usePublicIpAddressPermission', 'type': 'str'}, - 'shared_public_ip_address_configuration': {'key': 'sharedPublicIpAddressConfiguration', 'type': 'SubnetSharedPublicIpAddressConfigurationFragment'}, - 'virtual_network_pool_name': {'key': 'virtualNetworkPoolName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubnetOverrideFragment, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.lab_subnet_name = kwargs.get('lab_subnet_name', None) - self.use_in_vm_creation_permission = kwargs.get('use_in_vm_creation_permission', None) - self.use_public_ip_address_permission = kwargs.get('use_public_ip_address_permission', None) - self.shared_public_ip_address_configuration = kwargs.get('shared_public_ip_address_configuration', None) - self.virtual_network_pool_name = kwargs.get('virtual_network_pool_name', None) - - -class SubnetSharedPublicIpAddressConfiguration(msrest.serialization.Model): - """Configuration for public IP address sharing. - - :param allowed_ports: Backend ports that virtual machines on this subnet are allowed to expose. - :type allowed_ports: list[~azure.mgmt.devtestlabs.models.Port] - """ - - _attribute_map = { - 'allowed_ports': {'key': 'allowedPorts', 'type': '[Port]'}, - } - - def __init__( - self, - **kwargs - ): - super(SubnetSharedPublicIpAddressConfiguration, self).__init__(**kwargs) - self.allowed_ports = kwargs.get('allowed_ports', None) - - -class SubnetSharedPublicIpAddressConfigurationFragment(msrest.serialization.Model): - """Configuration for public IP address sharing. - - :param allowed_ports: Backend ports that virtual machines on this subnet are allowed to expose. - :type allowed_ports: list[~azure.mgmt.devtestlabs.models.PortFragment] - """ - - _attribute_map = { - 'allowed_ports': {'key': 'allowedPorts', 'type': '[PortFragment]'}, - } - - def __init__( - self, - **kwargs - ): - super(SubnetSharedPublicIpAddressConfigurationFragment, self).__init__(**kwargs) - self.allowed_ports = kwargs.get('allowed_ports', None) - - -class TargetCostProperties(msrest.serialization.Model): - """Properties of a cost target. - - :param status: Target cost status. Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.TargetCostStatus - :param target: Lab target cost. - :type target: int - :param cost_thresholds: Cost thresholds. - :type cost_thresholds: list[~azure.mgmt.devtestlabs.models.CostThresholdProperties] - :param cycle_start_date_time: Reporting cycle start date. - :type cycle_start_date_time: ~datetime.datetime - :param cycle_end_date_time: Reporting cycle end date. - :type cycle_end_date_time: ~datetime.datetime - :param cycle_type: Reporting cycle type. Possible values include: "CalendarMonth", "Custom". - :type cycle_type: str or ~azure.mgmt.devtestlabs.models.ReportingCycleType - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'int'}, - 'cost_thresholds': {'key': 'costThresholds', 'type': '[CostThresholdProperties]'}, - 'cycle_start_date_time': {'key': 'cycleStartDateTime', 'type': 'iso-8601'}, - 'cycle_end_date_time': {'key': 'cycleEndDateTime', 'type': 'iso-8601'}, - 'cycle_type': {'key': 'cycleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TargetCostProperties, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.target = kwargs.get('target', None) - self.cost_thresholds = kwargs.get('cost_thresholds', None) - self.cycle_start_date_time = kwargs.get('cycle_start_date_time', None) - self.cycle_end_date_time = kwargs.get('cycle_end_date_time', None) - self.cycle_type = kwargs.get('cycle_type', None) - - -class User(Resource): - """Profile of a lab user. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the user. - :type identity: ~azure.mgmt.devtestlabs.models.UserIdentity - :param secret_store: The secret store of the user. - :type secret_store: ~azure.mgmt.devtestlabs.models.UserSecretStore - :ivar created_date: The creation date of the user profile. - :vartype created_date: ~datetime.datetime - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'identity': {'key': 'properties.identity', 'type': 'UserIdentity'}, - 'secret_store': {'key': 'properties.secretStore', 'type': 'UserSecretStore'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.secret_store = kwargs.get('secret_store', None) - self.created_date = None - self.provisioning_state = None - self.unique_identifier = None - - -class UserFragment(UpdateResource): - """Profile of a lab user. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the user. - :type identity: ~azure.mgmt.devtestlabs.models.UserIdentityFragment - :param secret_store: The secret store of the user. - :type secret_store: ~azure.mgmt.devtestlabs.models.UserSecretStoreFragment - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'properties.identity', 'type': 'UserIdentityFragment'}, - 'secret_store': {'key': 'properties.secretStore', 'type': 'UserSecretStoreFragment'}, - } - - def __init__( - self, - **kwargs - ): - super(UserFragment, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.secret_store = kwargs.get('secret_store', None) - - -class UserIdentity(msrest.serialization.Model): - """Identity attributes of a lab user. - - :param principal_name: Set to the principal name / UPN of the client JWT making the request. - :type principal_name: str - :param principal_id: Set to the principal Id of the client JWT making the request. Service - principal will not have the principal Id. - :type principal_id: str - :param tenant_id: Set to the tenant ID of the client JWT making the request. - :type tenant_id: str - :param object_id: Set to the object Id of the client JWT making the request. Not all users have - object Id. For CSP (reseller) scenarios for example, object Id is not available. - :type object_id: str - :param app_id: Set to the app Id of the client JWT making the request. - :type app_id: str - """ - - _attribute_map = { - 'principal_name': {'key': 'principalName', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'app_id': {'key': 'appId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserIdentity, self).__init__(**kwargs) - self.principal_name = kwargs.get('principal_name', None) - self.principal_id = kwargs.get('principal_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.object_id = kwargs.get('object_id', None) - self.app_id = kwargs.get('app_id', None) - - -class UserIdentityFragment(msrest.serialization.Model): - """Identity attributes of a lab user. - - :param principal_name: Set to the principal name / UPN of the client JWT making the request. - :type principal_name: str - :param principal_id: Set to the principal Id of the client JWT making the request. Service - principal will not have the principal Id. - :type principal_id: str - :param tenant_id: Set to the tenant ID of the client JWT making the request. - :type tenant_id: str - :param object_id: Set to the object Id of the client JWT making the request. Not all users have - object Id. For CSP (reseller) scenarios for example, object Id is not available. - :type object_id: str - :param app_id: Set to the app Id of the client JWT making the request. - :type app_id: str - """ - - _attribute_map = { - 'principal_name': {'key': 'principalName', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'app_id': {'key': 'appId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserIdentityFragment, self).__init__(**kwargs) - self.principal_name = kwargs.get('principal_name', None) - self.principal_id = kwargs.get('principal_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.object_id = kwargs.get('object_id', None) - self.app_id = kwargs.get('app_id', None) - - -class UserList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.User] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class UserSecretStore(msrest.serialization.Model): - """Properties of a user's secret store. - - :param key_vault_uri: The URI of the user's Key vault. - :type key_vault_uri: str - :param key_vault_id: The ID of the user's Key vault. - :type key_vault_id: str - """ - - _attribute_map = { - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserSecretStore, self).__init__(**kwargs) - self.key_vault_uri = kwargs.get('key_vault_uri', None) - self.key_vault_id = kwargs.get('key_vault_id', None) - - -class UserSecretStoreFragment(msrest.serialization.Model): - """Properties of a user's secret store. - - :param key_vault_uri: The URI of the user's Key vault. - :type key_vault_uri: str - :param key_vault_id: The ID of the user's Key vault. - :type key_vault_id: str - """ - - _attribute_map = { - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserSecretStoreFragment, self).__init__(**kwargs) - self.key_vault_uri = kwargs.get('key_vault_uri', None) - self.key_vault_id = kwargs.get('key_vault_id', None) - - -class VirtualNetwork(Resource): - """A virtual network. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The identifier of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param allowed_subnets: The allowed subnets of the virtual network. - :type allowed_subnets: list[~azure.mgmt.devtestlabs.models.Subnet] - :param description: The description of the virtual network. - :type description: str - :param external_provider_resource_id: The Microsoft.Network resource identifier of the virtual - network. - :type external_provider_resource_id: str - :ivar external_subnets: The external subnet properties. - :vartype external_subnets: list[~azure.mgmt.devtestlabs.models.ExternalSubnet] - :param subnet_overrides: The subnet overrides of the virtual network. - :type subnet_overrides: list[~azure.mgmt.devtestlabs.models.SubnetOverride] - :ivar created_date: The creation date of the virtual network. - :vartype created_date: ~datetime.datetime - :ivar provisioning_state: The provisioning status of the resource. - :vartype provisioning_state: str - :ivar unique_identifier: The unique immutable identifier of a resource (Guid). - :vartype unique_identifier: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'external_subnets': {'readonly': True}, - 'created_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'unique_identifier': {'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}'}, - 'allowed_subnets': {'key': 'properties.allowedSubnets', 'type': '[Subnet]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'external_provider_resource_id': {'key': 'properties.externalProviderResourceId', 'type': 'str'}, - 'external_subnets': {'key': 'properties.externalSubnets', 'type': '[ExternalSubnet]'}, - 'subnet_overrides': {'key': 'properties.subnetOverrides', 'type': '[SubnetOverride]'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetwork, self).__init__(**kwargs) - self.allowed_subnets = kwargs.get('allowed_subnets', None) - self.description = kwargs.get('description', None) - self.external_provider_resource_id = kwargs.get('external_provider_resource_id', None) - self.external_subnets = None - self.subnet_overrides = kwargs.get('subnet_overrides', None) - self.created_date = None - self.provisioning_state = None - self.unique_identifier = None - - -class VirtualNetworkFragment(UpdateResource): - """A virtual network. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param allowed_subnets: The allowed subnets of the virtual network. - :type allowed_subnets: list[~azure.mgmt.devtestlabs.models.SubnetFragment] - :param description: The description of the virtual network. - :type description: str - :param external_provider_resource_id: The Microsoft.Network resource identifier of the virtual - network. - :type external_provider_resource_id: str - :param subnet_overrides: The subnet overrides of the virtual network. - :type subnet_overrides: list[~azure.mgmt.devtestlabs.models.SubnetOverrideFragment] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'allowed_subnets': {'key': 'properties.allowedSubnets', 'type': '[SubnetFragment]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'external_provider_resource_id': {'key': 'properties.externalProviderResourceId', 'type': 'str'}, - 'subnet_overrides': {'key': 'properties.subnetOverrides', 'type': '[SubnetOverrideFragment]'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkFragment, self).__init__(**kwargs) - self.allowed_subnets = kwargs.get('allowed_subnets', None) - self.description = kwargs.get('description', None) - self.external_provider_resource_id = kwargs.get('external_provider_resource_id', None) - self.subnet_overrides = kwargs.get('subnet_overrides', None) - - -class VirtualNetworkList(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.VirtualNetwork] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[VirtualNetwork]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class WeekDetails(msrest.serialization.Model): - """Properties of a weekly schedule. - - :param weekdays: The days of the week for which the schedule is set (e.g. Sunday, Monday, - Tuesday, etc.). - :type weekdays: list[str] - :param time: The time of the day the schedule will occur. - :type time: str - """ - - _attribute_map = { - 'weekdays': {'key': 'weekdays', 'type': '[str]'}, - 'time': {'key': 'time', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WeekDetails, self).__init__(**kwargs) - self.weekdays = kwargs.get('weekdays', None) - self.time = kwargs.get('time', None) - - -class WeekDetailsFragment(msrest.serialization.Model): - """Properties of a weekly schedule. - - :param weekdays: The days of the week for which the schedule is set (e.g. Sunday, Monday, - Tuesday, etc.). - :type weekdays: list[str] - :param time: The time of the day the schedule will occur. - :type time: str - """ - - _attribute_map = { - 'weekdays': {'key': 'weekdays', 'type': '[str]'}, - 'time': {'key': 'time', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WeekDetailsFragment, self).__init__(**kwargs) - self.weekdays = kwargs.get('weekdays', None) - self.time = kwargs.get('time', None) - - -class WindowsOsInfo(msrest.serialization.Model): - """Information about a Windows OS. - - :param windows_os_state: The state of the Windows OS (i.e. NonSysprepped, SysprepRequested, - SysprepApplied). Possible values include: "NonSysprepped", "SysprepRequested", - "SysprepApplied". - :type windows_os_state: str or ~azure.mgmt.devtestlabs.models.WindowsOsState - """ - - _attribute_map = { - 'windows_os_state': {'key': 'windowsOsState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WindowsOsInfo, self).__init__(**kwargs) - self.windows_os_state = kwargs.get('windows_os_state', None) - - -class WindowsOsInfoFragment(msrest.serialization.Model): - """Information about a Windows OS. - - :param windows_os_state: The state of the Windows OS (i.e. NonSysprepped, SysprepRequested, - SysprepApplied). Possible values include: "NonSysprepped", "SysprepRequested", - "SysprepApplied". - :type windows_os_state: str or ~azure.mgmt.devtestlabs.models.WindowsOsState - """ - - _attribute_map = { - 'windows_os_state': {'key': 'windowsOsState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WindowsOsInfoFragment, self).__init__(**kwargs) - self.windows_os_state = kwargs.get('windows_os_state', None) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_models_py3.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_models_py3.py index 7a314fbee25d..27e44994a375 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_models_py3.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/_models_py3.py @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union import msrest.serialization @@ -25,10 +25,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _validation = { @@ -52,6 +52,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -71,16 +77,16 @@ class ApplicableSchedule(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param lab_vms_shutdown: The auto-shutdown schedule, if one has been set at the lab or lab + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar lab_vms_shutdown: The auto-shutdown schedule, if one has been set at the lab or lab resource level. - :type lab_vms_shutdown: ~azure.mgmt.devtestlabs.models.Schedule - :param lab_vms_startup: The auto-startup schedule, if one has been set at the lab or lab + :vartype lab_vms_shutdown: ~azure.mgmt.devtestlabs.models.Schedule + :ivar lab_vms_startup: The auto-startup schedule, if one has been set at the lab or lab resource level. - :type lab_vms_startup: ~azure.mgmt.devtestlabs.models.Schedule + :vartype lab_vms_startup: ~azure.mgmt.devtestlabs.models.Schedule """ _validation = { @@ -108,6 +114,18 @@ def __init__( lab_vms_startup: Optional["Schedule"] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword lab_vms_shutdown: The auto-shutdown schedule, if one has been set at the lab or lab + resource level. + :paramtype lab_vms_shutdown: ~azure.mgmt.devtestlabs.models.Schedule + :keyword lab_vms_startup: The auto-startup schedule, if one has been set at the lab or lab + resource level. + :paramtype lab_vms_startup: ~azure.mgmt.devtestlabs.models.Schedule + """ super(ApplicableSchedule, self).__init__(location=location, tags=tags, **kwargs) self.lab_vms_shutdown = lab_vms_shutdown self.lab_vms_startup = lab_vms_startup @@ -116,8 +134,8 @@ def __init__( class UpdateResource(msrest.serialization.Model): """Represents an update resource. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -130,6 +148,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(UpdateResource, self).__init__(**kwargs) self.tags = tags @@ -137,40 +159,32 @@ def __init__( class ApplicableScheduleFragment(UpdateResource): """Schedules applicable to a virtual machine. The schedules may have been defined on a VM or on lab level. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param lab_vms_shutdown: The auto-shutdown schedule, if one has been set at the lab or lab - resource level. - :type lab_vms_shutdown: ~azure.mgmt.devtestlabs.models.ScheduleFragment - :param lab_vms_startup: The auto-startup schedule, if one has been set at the lab or lab - resource level. - :type lab_vms_startup: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'lab_vms_shutdown': {'key': 'properties.labVmsShutdown', 'type': 'ScheduleFragment'}, - 'lab_vms_startup': {'key': 'properties.labVmsStartup', 'type': 'ScheduleFragment'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - lab_vms_shutdown: Optional["ScheduleFragment"] = None, - lab_vms_startup: Optional["ScheduleFragment"] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(ApplicableScheduleFragment, self).__init__(tags=tags, **kwargs) - self.lab_vms_shutdown = lab_vms_shutdown - self.lab_vms_startup = lab_vms_startup class ApplyArtifactsRequest(msrest.serialization.Model): """Request body for applying artifacts to a virtual machine. - :param artifacts: The list of artifacts to apply. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] + :ivar artifacts: The list of artifacts to apply. + :vartype artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] """ _attribute_map = { @@ -183,6 +197,10 @@ def __init__( artifacts: Optional[List["ArtifactInstallProperties"]] = None, **kwargs ): + """ + :keyword artifacts: The list of artifacts to apply. + :paramtype artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] + """ super(ApplyArtifactsRequest, self).__init__(**kwargs) self.artifacts = artifacts @@ -198,10 +216,10 @@ class ArmTemplate(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] :ivar display_name: The display name of the ARM template. :vartype display_name: str :ivar description: The description of the ARM template. @@ -211,7 +229,7 @@ class ArmTemplate(Resource): :ivar icon: The URI to the icon of the ARM template. :vartype icon: str :ivar contents: The contents of the ARM template. - :vartype contents: object + :vartype contents: any :ivar created_date: The creation date of the armTemplate. :vartype created_date: ~datetime.datetime :ivar parameters_value_files_info: File name and parameter values information from all @@ -259,6 +277,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(ArmTemplate, self).__init__(location=location, tags=tags, **kwargs) self.display_name = None self.description = None @@ -273,10 +297,10 @@ def __init__( class ArmTemplateInfo(msrest.serialization.Model): """Information about a generated ARM template. - :param template: The template's contents. - :type template: object - :param parameters: The parameters of the ARM template. - :type parameters: object + :ivar template: The template's contents. + :vartype template: any + :ivar parameters: The parameters of the ARM template. + :vartype parameters: any """ _attribute_map = { @@ -287,10 +311,16 @@ class ArmTemplateInfo(msrest.serialization.Model): def __init__( self, *, - template: Optional[object] = None, - parameters: Optional[object] = None, + template: Optional[Any] = None, + parameters: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template's contents. + :paramtype template: any + :keyword parameters: The parameters of the ARM template. + :paramtype parameters: any + """ super(ArmTemplateInfo, self).__init__(**kwargs) self.template = template self.parameters = parameters @@ -299,10 +329,10 @@ def __init__( class ArmTemplateList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.ArmTemplate] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.ArmTemplate] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -317,6 +347,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.ArmTemplate] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(ArmTemplateList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -325,10 +361,10 @@ def __init__( class ArmTemplateParameterProperties(msrest.serialization.Model): """Properties of an Azure Resource Manager template parameter. - :param name: The name of the template parameter. - :type name: str - :param value: The value of the template parameter. - :type value: str + :ivar name: The name of the template parameter. + :vartype name: str + :ivar value: The value of the template parameter. + :vartype value: str """ _attribute_map = { @@ -343,37 +379,17 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the template parameter. + :paramtype name: str + :keyword value: The value of the template parameter. + :paramtype value: str + """ super(ArmTemplateParameterProperties, self).__init__(**kwargs) self.name = name self.value = value -class ArmTemplateParameterPropertiesFragment(msrest.serialization.Model): - """Properties of an Azure Resource Manager template parameter. - - :param name: The name of the template parameter. - :type name: str - :param value: The value of the template parameter. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - **kwargs - ): - super(ArmTemplateParameterPropertiesFragment, self).__init__(**kwargs) - self.name = name - self.value = value - - class Artifact(Resource): """An artifact. @@ -385,10 +401,10 @@ class Artifact(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] :ivar title: The artifact's title. :vartype title: str :ivar description: The artifact's description. @@ -402,7 +418,7 @@ class Artifact(Resource): :ivar target_os_type: The artifact's target OS. :vartype target_os_type: str :ivar parameters: The artifact's parameters. - :vartype parameters: object + :vartype parameters: any :ivar created_date: The artifact's creation date. :vartype created_date: ~datetime.datetime """ @@ -444,6 +460,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(Artifact, self).__init__(location=location, tags=tags, **kwargs) self.title = None self.description = None @@ -458,12 +480,12 @@ def __init__( class ArtifactDeploymentStatusProperties(msrest.serialization.Model): """Properties of an artifact deployment. - :param deployment_status: The deployment status of the artifact. - :type deployment_status: str - :param artifacts_applied: The total count of the artifacts that were successfully applied. - :type artifacts_applied: int - :param total_artifacts: The total count of the artifacts that were tentatively applied. - :type total_artifacts: int + :ivar deployment_status: The deployment status of the artifact. + :vartype deployment_status: str + :ivar artifacts_applied: The total count of the artifacts that were successfully applied. + :vartype artifacts_applied: int + :ivar total_artifacts: The total count of the artifacts that were tentatively applied. + :vartype total_artifacts: int """ _attribute_map = { @@ -480,60 +502,37 @@ def __init__( total_artifacts: Optional[int] = None, **kwargs ): + """ + :keyword deployment_status: The deployment status of the artifact. + :paramtype deployment_status: str + :keyword artifacts_applied: The total count of the artifacts that were successfully applied. + :paramtype artifacts_applied: int + :keyword total_artifacts: The total count of the artifacts that were tentatively applied. + :paramtype total_artifacts: int + """ super(ArtifactDeploymentStatusProperties, self).__init__(**kwargs) self.deployment_status = deployment_status self.artifacts_applied = artifacts_applied self.total_artifacts = total_artifacts -class ArtifactDeploymentStatusPropertiesFragment(msrest.serialization.Model): - """Properties of an artifact deployment. - - :param deployment_status: The deployment status of the artifact. - :type deployment_status: str - :param artifacts_applied: The total count of the artifacts that were successfully applied. - :type artifacts_applied: int - :param total_artifacts: The total count of the artifacts that were tentatively applied. - :type total_artifacts: int - """ - - _attribute_map = { - 'deployment_status': {'key': 'deploymentStatus', 'type': 'str'}, - 'artifacts_applied': {'key': 'artifactsApplied', 'type': 'int'}, - 'total_artifacts': {'key': 'totalArtifacts', 'type': 'int'}, - } - - def __init__( - self, - *, - deployment_status: Optional[str] = None, - artifacts_applied: Optional[int] = None, - total_artifacts: Optional[int] = None, - **kwargs - ): - super(ArtifactDeploymentStatusPropertiesFragment, self).__init__(**kwargs) - self.deployment_status = deployment_status - self.artifacts_applied = artifacts_applied - self.total_artifacts = total_artifacts - - class ArtifactInstallProperties(msrest.serialization.Model): """Properties of an artifact. - :param artifact_id: The artifact's identifier. - :type artifact_id: str - :param artifact_title: The artifact's title. - :type artifact_title: str - :param parameters: The parameters of the artifact. - :type parameters: list[~azure.mgmt.devtestlabs.models.ArtifactParameterProperties] - :param status: The status of the artifact. - :type status: str - :param deployment_status_message: The status message from the deployment. - :type deployment_status_message: str - :param vm_extension_status_message: The status message from the virtual machine extension. - :type vm_extension_status_message: str - :param install_time: The time that the artifact starts to install on the virtual machine. - :type install_time: ~datetime.datetime + :ivar artifact_id: The artifact's identifier. + :vartype artifact_id: str + :ivar artifact_title: The artifact's title. + :vartype artifact_title: str + :ivar parameters: The parameters of the artifact. + :vartype parameters: list[~azure.mgmt.devtestlabs.models.ArtifactParameterProperties] + :ivar status: The status of the artifact. + :vartype status: str + :ivar deployment_status_message: The status message from the deployment. + :vartype deployment_status_message: str + :ivar vm_extension_status_message: The status message from the virtual machine extension. + :vartype vm_extension_status_message: str + :ivar install_time: The time that the artifact starts to install on the virtual machine. + :vartype install_time: ~datetime.datetime """ _attribute_map = { @@ -558,6 +557,22 @@ def __init__( install_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword artifact_id: The artifact's identifier. + :paramtype artifact_id: str + :keyword artifact_title: The artifact's title. + :paramtype artifact_title: str + :keyword parameters: The parameters of the artifact. + :paramtype parameters: list[~azure.mgmt.devtestlabs.models.ArtifactParameterProperties] + :keyword status: The status of the artifact. + :paramtype status: str + :keyword deployment_status_message: The status message from the deployment. + :paramtype deployment_status_message: str + :keyword vm_extension_status_message: The status message from the virtual machine extension. + :paramtype vm_extension_status_message: str + :keyword install_time: The time that the artifact starts to install on the virtual machine. + :paramtype install_time: ~datetime.datetime + """ super(ArtifactInstallProperties, self).__init__(**kwargs) self.artifact_id = artifact_id self.artifact_title = artifact_title @@ -568,64 +583,13 @@ def __init__( self.install_time = install_time -class ArtifactInstallPropertiesFragment(msrest.serialization.Model): - """Properties of an artifact. - - :param artifact_id: The artifact's identifier. - :type artifact_id: str - :param artifact_title: The artifact's title. - :type artifact_title: str - :param parameters: The parameters of the artifact. - :type parameters: list[~azure.mgmt.devtestlabs.models.ArtifactParameterPropertiesFragment] - :param status: The status of the artifact. - :type status: str - :param deployment_status_message: The status message from the deployment. - :type deployment_status_message: str - :param vm_extension_status_message: The status message from the virtual machine extension. - :type vm_extension_status_message: str - :param install_time: The time that the artifact starts to install on the virtual machine. - :type install_time: ~datetime.datetime - """ - - _attribute_map = { - 'artifact_id': {'key': 'artifactId', 'type': 'str'}, - 'artifact_title': {'key': 'artifactTitle', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ArtifactParameterPropertiesFragment]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'deployment_status_message': {'key': 'deploymentStatusMessage', 'type': 'str'}, - 'vm_extension_status_message': {'key': 'vmExtensionStatusMessage', 'type': 'str'}, - 'install_time': {'key': 'installTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - artifact_id: Optional[str] = None, - artifact_title: Optional[str] = None, - parameters: Optional[List["ArtifactParameterPropertiesFragment"]] = None, - status: Optional[str] = None, - deployment_status_message: Optional[str] = None, - vm_extension_status_message: Optional[str] = None, - install_time: Optional[datetime.datetime] = None, - **kwargs - ): - super(ArtifactInstallPropertiesFragment, self).__init__(**kwargs) - self.artifact_id = artifact_id - self.artifact_title = artifact_title - self.parameters = parameters - self.status = status - self.deployment_status_message = deployment_status_message - self.vm_extension_status_message = vm_extension_status_message - self.install_time = install_time - - class ArtifactList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Artifact] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.Artifact] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -640,6 +604,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.Artifact] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(ArtifactList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -648,10 +618,10 @@ def __init__( class ArtifactParameterProperties(msrest.serialization.Model): """Properties of an artifact parameter. - :param name: The name of the artifact parameter. - :type name: str - :param value: The value of the artifact parameter. - :type value: str + :ivar name: The name of the artifact parameter. + :vartype name: str + :ivar value: The value of the artifact parameter. + :vartype value: str """ _attribute_map = { @@ -666,37 +636,17 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the artifact parameter. + :paramtype name: str + :keyword value: The value of the artifact parameter. + :paramtype value: str + """ super(ArtifactParameterProperties, self).__init__(**kwargs) self.name = name self.value = value -class ArtifactParameterPropertiesFragment(msrest.serialization.Model): - """Properties of an artifact parameter. - - :param name: The name of the artifact parameter. - :type name: str - :param value: The value of the artifact parameter. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - **kwargs - ): - super(ArtifactParameterPropertiesFragment, self).__init__(**kwargs) - self.name = name - self.value = value - - class ArtifactSource(Resource): """Properties of an artifact source. @@ -708,27 +658,28 @@ class ArtifactSource(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param display_name: The artifact source's display name. - :type display_name: str - :param uri: The artifact source's URI. - :type uri: str - :param source_type: The artifact source's type. Possible values include: "VsoGit", "GitHub". - :type source_type: str or ~azure.mgmt.devtestlabs.models.SourceControlType - :param folder_path: The folder containing artifacts. - :type folder_path: str - :param arm_template_folder_path: The folder containing Azure Resource Manager templates. - :type arm_template_folder_path: str - :param branch_ref: The artifact source's branch reference. - :type branch_ref: str - :param security_token: The security token to authenticate to the artifact source. - :type security_token: str - :param status: Indicates if the artifact source is enabled (values: Enabled, Disabled). - Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar display_name: The artifact source's display name. + :vartype display_name: str + :ivar uri: The artifact source's URI. + :vartype uri: str + :ivar source_type: The artifact source's type. Possible values include: "VsoGit", "GitHub", + "StorageAccount". + :vartype source_type: str or ~azure.mgmt.devtestlabs.models.SourceControlType + :ivar folder_path: The folder containing artifacts. + :vartype folder_path: str + :ivar arm_template_folder_path: The folder containing Azure Resource Manager templates. + :vartype arm_template_folder_path: str + :ivar branch_ref: The artifact source's branch reference. + :vartype branch_ref: str + :ivar security_token: The security token to authenticate to the artifact source. + :vartype security_token: str + :ivar status: Indicates if the artifact source is enabled (values: Enabled, Disabled). Possible + values include: "Enabled", "Disabled". + :vartype status: str or ~azure.mgmt.devtestlabs.models.EnableStatus :ivar created_date: The artifact source's creation date. :vartype created_date: ~datetime.datetime :ivar provisioning_state: The provisioning status of the resource. @@ -780,6 +731,30 @@ def __init__( status: Optional[Union[str, "EnableStatus"]] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword display_name: The artifact source's display name. + :paramtype display_name: str + :keyword uri: The artifact source's URI. + :paramtype uri: str + :keyword source_type: The artifact source's type. Possible values include: "VsoGit", "GitHub", + "StorageAccount". + :paramtype source_type: str or ~azure.mgmt.devtestlabs.models.SourceControlType + :keyword folder_path: The folder containing artifacts. + :paramtype folder_path: str + :keyword arm_template_folder_path: The folder containing Azure Resource Manager templates. + :paramtype arm_template_folder_path: str + :keyword branch_ref: The artifact source's branch reference. + :paramtype branch_ref: str + :keyword security_token: The security token to authenticate to the artifact source. + :paramtype security_token: str + :keyword status: Indicates if the artifact source is enabled (values: Enabled, Disabled). + Possible values include: "Enabled", "Disabled". + :paramtype status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + """ super(ArtifactSource, self).__init__(location=location, tags=tags, **kwargs) self.display_name = display_name self.uri = uri @@ -797,71 +772,34 @@ def __init__( class ArtifactSourceFragment(UpdateResource): """Properties of an artifact source. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param display_name: The artifact source's display name. - :type display_name: str - :param uri: The artifact source's URI. - :type uri: str - :param source_type: The artifact source's type. Possible values include: "VsoGit", "GitHub". - :type source_type: str or ~azure.mgmt.devtestlabs.models.SourceControlType - :param folder_path: The folder containing artifacts. - :type folder_path: str - :param arm_template_folder_path: The folder containing Azure Resource Manager templates. - :type arm_template_folder_path: str - :param branch_ref: The artifact source's branch reference. - :type branch_ref: str - :param security_token: The security token to authenticate to the artifact source. - :type security_token: str - :param status: Indicates if the artifact source is enabled (values: Enabled, Disabled). - Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'source_type': {'key': 'properties.sourceType', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'arm_template_folder_path': {'key': 'properties.armTemplateFolderPath', 'type': 'str'}, - 'branch_ref': {'key': 'properties.branchRef', 'type': 'str'}, - 'security_token': {'key': 'properties.securityToken', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - display_name: Optional[str] = None, - uri: Optional[str] = None, - source_type: Optional[Union[str, "SourceControlType"]] = None, - folder_path: Optional[str] = None, - arm_template_folder_path: Optional[str] = None, - branch_ref: Optional[str] = None, - security_token: Optional[str] = None, - status: Optional[Union[str, "EnableStatus"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(ArtifactSourceFragment, self).__init__(tags=tags, **kwargs) - self.display_name = display_name - self.uri = uri - self.source_type = source_type - self.folder_path = folder_path - self.arm_template_folder_path = arm_template_folder_path - self.branch_ref = branch_ref - self.security_token = security_token - self.status = status class ArtifactSourceList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.ArtifactSource] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.ArtifactSource] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -876,6 +814,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.ArtifactSource] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(ArtifactSourceList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -884,9 +828,9 @@ def __init__( class AttachDiskProperties(msrest.serialization.Model): """Properties of the disk to attach. - :param leased_by_lab_vm_id: The resource ID of the Lab virtual machine to which the disk is + :ivar leased_by_lab_vm_id: The resource ID of the Lab virtual machine to which the disk is attached. - :type leased_by_lab_vm_id: str + :vartype leased_by_lab_vm_id: str """ _attribute_map = { @@ -899,6 +843,11 @@ def __init__( leased_by_lab_vm_id: Optional[str] = None, **kwargs ): + """ + :keyword leased_by_lab_vm_id: The resource ID of the Lab virtual machine to which the disk is + attached. + :paramtype leased_by_lab_vm_id: str + """ super(AttachDiskProperties, self).__init__(**kwargs) self.leased_by_lab_vm_id = leased_by_lab_vm_id @@ -906,13 +855,13 @@ def __init__( class AttachNewDataDiskOptions(msrest.serialization.Model): """Properties to attach new disk to the Virtual Machine. - :param disk_size_gi_b: Size of the disk to be attached in GibiBytes. - :type disk_size_gi_b: int - :param disk_name: The name of the disk to be attached. - :type disk_name: str - :param disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values + :ivar disk_size_gi_b: Size of the disk to be attached in Gibibytes. + :vartype disk_size_gi_b: int + :ivar disk_name: The name of the disk to be attached. + :vartype disk_name: str + :ivar disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values include: "Standard", "Premium", "StandardSSD". - :type disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType + :vartype disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType """ _attribute_map = { @@ -929,49 +878,26 @@ def __init__( disk_type: Optional[Union[str, "StorageType"]] = None, **kwargs ): + """ + :keyword disk_size_gi_b: Size of the disk to be attached in Gibibytes. + :paramtype disk_size_gi_b: int + :keyword disk_name: The name of the disk to be attached. + :paramtype disk_name: str + :keyword disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values + include: "Standard", "Premium", "StandardSSD". + :paramtype disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType + """ super(AttachNewDataDiskOptions, self).__init__(**kwargs) self.disk_size_gi_b = disk_size_gi_b self.disk_name = disk_name self.disk_type = disk_type -class AttachNewDataDiskOptionsFragment(msrest.serialization.Model): - """Properties to attach new disk to the Virtual Machine. - - :param disk_size_gi_b: Size of the disk to be attached in GibiBytes. - :type disk_size_gi_b: int - :param disk_name: The name of the disk to be attached. - :type disk_name: str - :param disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values - include: "Standard", "Premium", "StandardSSD". - :type disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType - """ - - _attribute_map = { - 'disk_size_gi_b': {'key': 'diskSizeGiB', 'type': 'int'}, - 'disk_name': {'key': 'diskName', 'type': 'str'}, - 'disk_type': {'key': 'diskType', 'type': 'str'}, - } - - def __init__( - self, - *, - disk_size_gi_b: Optional[int] = None, - disk_name: Optional[str] = None, - disk_type: Optional[Union[str, "StorageType"]] = None, - **kwargs - ): - super(AttachNewDataDiskOptionsFragment, self).__init__(**kwargs) - self.disk_size_gi_b = disk_size_gi_b - self.disk_name = disk_name - self.disk_type = disk_type - - class BulkCreationParameters(msrest.serialization.Model): """Parameters for creating multiple virtual machines as a single action. - :param instance_count: The number of virtual machine instances to create. - :type instance_count: int + :ivar instance_count: The number of virtual machine instances to create. + :vartype instance_count: int """ _attribute_map = { @@ -984,42 +910,25 @@ def __init__( instance_count: Optional[int] = None, **kwargs ): + """ + :keyword instance_count: The number of virtual machine instances to create. + :paramtype instance_count: int + """ super(BulkCreationParameters, self).__init__(**kwargs) self.instance_count = instance_count -class BulkCreationParametersFragment(msrest.serialization.Model): - """Parameters for creating multiple virtual machines as a single action. - - :param instance_count: The number of virtual machine instances to create. - :type instance_count: int - """ - - _attribute_map = { - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - } - - def __init__( - self, - *, - instance_count: Optional[int] = None, - **kwargs - ): - super(BulkCreationParametersFragment, self).__init__(**kwargs) - self.instance_count = instance_count - - class CloudErrorBody(msrest.serialization.Model): """Body of an error from a REST request. - :param code: The error code. - :type code: str - :param message: The error message. - :type message: str - :param target: The error target. - :type target: str - :param details: Inner errors. - :type details: list[~azure.mgmt.devtestlabs.models.CloudErrorBody] + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: Inner errors. + :vartype details: list[~azure.mgmt.devtestlabs.models.CloudErrorBody] """ _attribute_map = { @@ -1038,6 +947,16 @@ def __init__( details: Optional[List["CloudErrorBody"]] = None, **kwargs ): + """ + :keyword code: The error code. + :paramtype code: str + :keyword message: The error message. + :paramtype message: str + :keyword target: The error target. + :paramtype target: str + :keyword details: Inner errors. + :paramtype details: list[~azure.mgmt.devtestlabs.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -1048,15 +967,15 @@ def __init__( class ComputeDataDisk(msrest.serialization.Model): """A data disks attached to a virtual machine. - :param name: Gets data disk name. - :type name: str - :param disk_uri: When backed by a blob, the URI of underlying blob. - :type disk_uri: str - :param managed_disk_id: When backed by managed disk, this is the ID of the compute disk + :ivar name: Gets data disk name. + :vartype name: str + :ivar disk_uri: When backed by a blob, the URI of underlying blob. + :vartype disk_uri: str + :ivar managed_disk_id: When backed by managed disk, this is the ID of the compute disk resource. - :type managed_disk_id: str - :param disk_size_gi_b: Gets data disk size in GiB. - :type disk_size_gi_b: int + :vartype managed_disk_id: str + :ivar disk_size_gi_b: Gets data disk size in GiB. + :vartype disk_size_gi_b: int """ _attribute_map = { @@ -1075,6 +994,17 @@ def __init__( disk_size_gi_b: Optional[int] = None, **kwargs ): + """ + :keyword name: Gets data disk name. + :paramtype name: str + :keyword disk_uri: When backed by a blob, the URI of underlying blob. + :paramtype disk_uri: str + :keyword managed_disk_id: When backed by managed disk, this is the ID of the compute disk + resource. + :paramtype managed_disk_id: str + :keyword disk_size_gi_b: Gets data disk size in GiB. + :paramtype disk_size_gi_b: int + """ super(ComputeDataDisk, self).__init__(**kwargs) self.name = name self.disk_uri = disk_uri @@ -1082,52 +1012,15 @@ def __init__( self.disk_size_gi_b = disk_size_gi_b -class ComputeDataDiskFragment(msrest.serialization.Model): - """A data disks attached to a virtual machine. - - :param name: Gets data disk name. - :type name: str - :param disk_uri: When backed by a blob, the URI of underlying blob. - :type disk_uri: str - :param managed_disk_id: When backed by managed disk, this is the ID of the compute disk - resource. - :type managed_disk_id: str - :param disk_size_gi_b: Gets data disk size in GiB. - :type disk_size_gi_b: int - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'disk_uri': {'key': 'diskUri', 'type': 'str'}, - 'managed_disk_id': {'key': 'managedDiskId', 'type': 'str'}, - 'disk_size_gi_b': {'key': 'diskSizeGiB', 'type': 'int'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - disk_uri: Optional[str] = None, - managed_disk_id: Optional[str] = None, - disk_size_gi_b: Optional[int] = None, - **kwargs - ): - super(ComputeDataDiskFragment, self).__init__(**kwargs) - self.name = name - self.disk_uri = disk_uri - self.managed_disk_id = managed_disk_id - self.disk_size_gi_b = disk_size_gi_b - - class ComputeVmInstanceViewStatus(msrest.serialization.Model): """Status information about a virtual machine. - :param code: Gets the status Code. - :type code: str - :param display_status: Gets the short localizable label for the status. - :type display_status: str - :param message: Gets the message associated with the status. - :type message: str + :ivar code: Gets the status Code. + :vartype code: str + :ivar display_status: Gets the short localizable label for the status. + :vartype display_status: str + :ivar message: Gets the message associated with the status. + :vartype message: str """ _attribute_map = { @@ -1144,60 +1037,37 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Gets the status Code. + :paramtype code: str + :keyword display_status: Gets the short localizable label for the status. + :paramtype display_status: str + :keyword message: Gets the message associated with the status. + :paramtype message: str + """ super(ComputeVmInstanceViewStatus, self).__init__(**kwargs) self.code = code self.display_status = display_status self.message = message -class ComputeVmInstanceViewStatusFragment(msrest.serialization.Model): - """Status information about a virtual machine. - - :param code: Gets the status Code. - :type code: str - :param display_status: Gets the short localizable label for the status. - :type display_status: str - :param message: Gets the message associated with the status. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): - super(ComputeVmInstanceViewStatusFragment, self).__init__(**kwargs) - self.code = code - self.display_status = display_status - self.message = message - - class ComputeVmProperties(msrest.serialization.Model): """Properties of a virtual machine returned by the Microsoft.Compute API. - :param statuses: Gets the statuses of the virtual machine. - :type statuses: list[~azure.mgmt.devtestlabs.models.ComputeVmInstanceViewStatus] - :param os_type: Gets the OS type of the virtual machine. - :type os_type: str - :param vm_size: Gets the size of the virtual machine. - :type vm_size: str - :param network_interface_id: Gets the network interface ID of the virtual machine. - :type network_interface_id: str - :param os_disk_id: Gets OS disk blob uri for the virtual machine. - :type os_disk_id: str - :param data_disk_ids: Gets data disks blob uri for the virtual machine. - :type data_disk_ids: list[str] - :param data_disks: Gets all data disks attached to the virtual machine. - :type data_disks: list[~azure.mgmt.devtestlabs.models.ComputeDataDisk] + :ivar statuses: Gets the statuses of the virtual machine. + :vartype statuses: list[~azure.mgmt.devtestlabs.models.ComputeVmInstanceViewStatus] + :ivar os_type: Gets the OS type of the virtual machine. + :vartype os_type: str + :ivar vm_size: Gets the size of the virtual machine. + :vartype vm_size: str + :ivar network_interface_id: Gets the network interface ID of the virtual machine. + :vartype network_interface_id: str + :ivar os_disk_id: Gets OS disk blob uri for the virtual machine. + :vartype os_disk_id: str + :ivar data_disk_ids: Gets data disks blob uri for the virtual machine. + :vartype data_disk_ids: list[str] + :ivar data_disks: Gets all data disks attached to the virtual machine. + :vartype data_disks: list[~azure.mgmt.devtestlabs.models.ComputeDataDisk] """ _attribute_map = { @@ -1222,6 +1092,22 @@ def __init__( data_disks: Optional[List["ComputeDataDisk"]] = None, **kwargs ): + """ + :keyword statuses: Gets the statuses of the virtual machine. + :paramtype statuses: list[~azure.mgmt.devtestlabs.models.ComputeVmInstanceViewStatus] + :keyword os_type: Gets the OS type of the virtual machine. + :paramtype os_type: str + :keyword vm_size: Gets the size of the virtual machine. + :paramtype vm_size: str + :keyword network_interface_id: Gets the network interface ID of the virtual machine. + :paramtype network_interface_id: str + :keyword os_disk_id: Gets OS disk blob uri for the virtual machine. + :paramtype os_disk_id: str + :keyword data_disk_ids: Gets data disks blob uri for the virtual machine. + :paramtype data_disk_ids: list[str] + :keyword data_disks: Gets all data disks attached to the virtual machine. + :paramtype data_disks: list[~azure.mgmt.devtestlabs.models.ComputeDataDisk] + """ super(ComputeVmProperties, self).__init__(**kwargs) self.statuses = statuses self.os_type = os_type @@ -1232,74 +1118,23 @@ def __init__( self.data_disks = data_disks -class ComputeVmPropertiesFragment(msrest.serialization.Model): - """Properties of a virtual machine returned by the Microsoft.Compute API. - - :param statuses: Gets the statuses of the virtual machine. - :type statuses: list[~azure.mgmt.devtestlabs.models.ComputeVmInstanceViewStatusFragment] - :param os_type: Gets the OS type of the virtual machine. - :type os_type: str - :param vm_size: Gets the size of the virtual machine. - :type vm_size: str - :param network_interface_id: Gets the network interface ID of the virtual machine. - :type network_interface_id: str - :param os_disk_id: Gets OS disk blob uri for the virtual machine. - :type os_disk_id: str - :param data_disk_ids: Gets data disks blob uri for the virtual machine. - :type data_disk_ids: list[str] - :param data_disks: Gets all data disks attached to the virtual machine. - :type data_disks: list[~azure.mgmt.devtestlabs.models.ComputeDataDiskFragment] - """ - - _attribute_map = { - 'statuses': {'key': 'statuses', 'type': '[ComputeVmInstanceViewStatusFragment]'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'network_interface_id': {'key': 'networkInterfaceId', 'type': 'str'}, - 'os_disk_id': {'key': 'osDiskId', 'type': 'str'}, - 'data_disk_ids': {'key': 'dataDiskIds', 'type': '[str]'}, - 'data_disks': {'key': 'dataDisks', 'type': '[ComputeDataDiskFragment]'}, - } - - def __init__( - self, - *, - statuses: Optional[List["ComputeVmInstanceViewStatusFragment"]] = None, - os_type: Optional[str] = None, - vm_size: Optional[str] = None, - network_interface_id: Optional[str] = None, - os_disk_id: Optional[str] = None, - data_disk_ids: Optional[List[str]] = None, - data_disks: Optional[List["ComputeDataDiskFragment"]] = None, - **kwargs - ): - super(ComputeVmPropertiesFragment, self).__init__(**kwargs) - self.statuses = statuses - self.os_type = os_type - self.vm_size = vm_size - self.network_interface_id = network_interface_id - self.os_disk_id = os_disk_id - self.data_disk_ids = data_disk_ids - self.data_disks = data_disks - - class CostThresholdProperties(msrest.serialization.Model): """Properties of a cost threshold item. - :param threshold_id: The ID of the cost threshold item. - :type threshold_id: str - :param percentage_threshold: The value of the percentage cost threshold. - :type percentage_threshold: ~azure.mgmt.devtestlabs.models.PercentageCostThresholdProperties - :param display_on_chart: Indicates whether this threshold will be displayed on cost charts. + :ivar threshold_id: The ID of the cost threshold item. + :vartype threshold_id: str + :ivar percentage_threshold: The value of the percentage cost threshold. + :vartype percentage_threshold: ~azure.mgmt.devtestlabs.models.PercentageCostThresholdProperties + :ivar display_on_chart: Indicates whether this threshold will be displayed on cost charts. Possible values include: "Enabled", "Disabled". - :type display_on_chart: str or ~azure.mgmt.devtestlabs.models.CostThresholdStatus - :param send_notification_when_exceeded: Indicates whether notifications will be sent when this + :vartype display_on_chart: str or ~azure.mgmt.devtestlabs.models.CostThresholdStatus + :ivar send_notification_when_exceeded: Indicates whether notifications will be sent when this threshold is exceeded. Possible values include: "Enabled", "Disabled". - :type send_notification_when_exceeded: str or + :vartype send_notification_when_exceeded: str or ~azure.mgmt.devtestlabs.models.CostThresholdStatus - :param notification_sent: Indicates the datetime when notifications were last sent for this + :ivar notification_sent: Indicates the datetime when notifications were last sent for this threshold. - :type notification_sent: str + :vartype notification_sent: str """ _attribute_map = { @@ -1320,6 +1155,23 @@ def __init__( notification_sent: Optional[str] = None, **kwargs ): + """ + :keyword threshold_id: The ID of the cost threshold item. + :paramtype threshold_id: str + :keyword percentage_threshold: The value of the percentage cost threshold. + :paramtype percentage_threshold: + ~azure.mgmt.devtestlabs.models.PercentageCostThresholdProperties + :keyword display_on_chart: Indicates whether this threshold will be displayed on cost charts. + Possible values include: "Enabled", "Disabled". + :paramtype display_on_chart: str or ~azure.mgmt.devtestlabs.models.CostThresholdStatus + :keyword send_notification_when_exceeded: Indicates whether notifications will be sent when + this threshold is exceeded. Possible values include: "Enabled", "Disabled". + :paramtype send_notification_when_exceeded: str or + ~azure.mgmt.devtestlabs.models.CostThresholdStatus + :keyword notification_sent: Indicates the datetime when notifications were last sent for this + threshold. + :paramtype notification_sent: str + """ super(CostThresholdProperties, self).__init__(**kwargs) self.threshold_id = threshold_id self.percentage_threshold = percentage_threshold @@ -1339,32 +1191,32 @@ class CustomImage(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param vm: The virtual machine from which the image is to be created. - :type vm: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromVm - :param vhd: The VHD from which the image is to be created. - :type vhd: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesCustom - :param description: The description of the custom image. - :type description: str - :param author: The author of the custom image. - :type author: str + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar vm: The virtual machine from which the image is to be created. + :vartype vm: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromVm + :ivar vhd: The VHD from which the image is to be created. + :vartype vhd: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesCustom + :ivar description: The description of the custom image. + :vartype description: str + :ivar author: The author of the custom image. + :vartype author: str :ivar creation_date: The creation date of the custom image. :vartype creation_date: ~datetime.datetime - :param managed_image_id: The Managed Image Id backing the custom image. - :type managed_image_id: str - :param managed_snapshot_id: The Managed Snapshot Id backing the custom image. - :type managed_snapshot_id: str - :param data_disk_storage_info: Storage information about the data disks present in the custom + :ivar managed_image_id: The Managed Image Id backing the custom image. + :vartype managed_image_id: str + :ivar managed_snapshot_id: The Managed Snapshot Id backing the custom image. + :vartype managed_snapshot_id: str + :ivar data_disk_storage_info: Storage information about the data disks present in the custom image. - :type data_disk_storage_info: list[~azure.mgmt.devtestlabs.models.DataDiskStorageTypeInfo] - :param custom_image_plan: Storage information about the plan related to this custom image. - :type custom_image_plan: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromPlan - :param is_plan_authorized: Whether or not the custom images underlying offer/plan has been + :vartype data_disk_storage_info: list[~azure.mgmt.devtestlabs.models.DataDiskStorageTypeInfo] + :ivar custom_image_plan: Storage information about the plan related to this custom image. + :vartype custom_image_plan: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromPlan + :ivar is_plan_authorized: Whether or not the custom images underlying offer/plan has been enabled for programmatic deployment. - :type is_plan_authorized: bool + :vartype is_plan_authorized: bool :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -1416,6 +1268,32 @@ def __init__( is_plan_authorized: Optional[bool] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword vm: The virtual machine from which the image is to be created. + :paramtype vm: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromVm + :keyword vhd: The VHD from which the image is to be created. + :paramtype vhd: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesCustom + :keyword description: The description of the custom image. + :paramtype description: str + :keyword author: The author of the custom image. + :paramtype author: str + :keyword managed_image_id: The Managed Image Id backing the custom image. + :paramtype managed_image_id: str + :keyword managed_snapshot_id: The Managed Snapshot Id backing the custom image. + :paramtype managed_snapshot_id: str + :keyword data_disk_storage_info: Storage information about the data disks present in the custom + image. + :paramtype data_disk_storage_info: list[~azure.mgmt.devtestlabs.models.DataDiskStorageTypeInfo] + :keyword custom_image_plan: Storage information about the plan related to this custom image. + :paramtype custom_image_plan: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromPlan + :keyword is_plan_authorized: Whether or not the custom images underlying offer/plan has been + enabled for programmatic deployment. + :paramtype is_plan_authorized: bool + """ super(CustomImage, self).__init__(location=location, tags=tags, **kwargs) self.vm = vm self.vhd = vhd @@ -1434,78 +1312,34 @@ def __init__( class CustomImageFragment(UpdateResource): """A custom image. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param vm: The virtual machine from which the image is to be created. - :type vm: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromVmFragment - :param vhd: The VHD from which the image is to be created. - :type vhd: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesCustomFragment - :param description: The description of the custom image. - :type description: str - :param author: The author of the custom image. - :type author: str - :param managed_image_id: The Managed Image Id backing the custom image. - :type managed_image_id: str - :param managed_snapshot_id: The Managed Snapshot Id backing the custom image. - :type managed_snapshot_id: str - :param data_disk_storage_info: Storage information about the data disks present in the custom - image. - :type data_disk_storage_info: - list[~azure.mgmt.devtestlabs.models.DataDiskStorageTypeInfoFragment] - :param custom_image_plan: Storage information about the plan related to this custom image. - :type custom_image_plan: ~azure.mgmt.devtestlabs.models.CustomImagePropertiesFromPlanFragment - :param is_plan_authorized: Whether or not the custom images underlying offer/plan has been - enabled for programmatic deployment. - :type is_plan_authorized: bool + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'vm': {'key': 'properties.vm', 'type': 'CustomImagePropertiesFromVmFragment'}, - 'vhd': {'key': 'properties.vhd', 'type': 'CustomImagePropertiesCustomFragment'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'managed_image_id': {'key': 'properties.managedImageId', 'type': 'str'}, - 'managed_snapshot_id': {'key': 'properties.managedSnapshotId', 'type': 'str'}, - 'data_disk_storage_info': {'key': 'properties.dataDiskStorageInfo', 'type': '[DataDiskStorageTypeInfoFragment]'}, - 'custom_image_plan': {'key': 'properties.customImagePlan', 'type': 'CustomImagePropertiesFromPlanFragment'}, - 'is_plan_authorized': {'key': 'properties.isPlanAuthorized', 'type': 'bool'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - vm: Optional["CustomImagePropertiesFromVmFragment"] = None, - vhd: Optional["CustomImagePropertiesCustomFragment"] = None, - description: Optional[str] = None, - author: Optional[str] = None, - managed_image_id: Optional[str] = None, - managed_snapshot_id: Optional[str] = None, - data_disk_storage_info: Optional[List["DataDiskStorageTypeInfoFragment"]] = None, - custom_image_plan: Optional["CustomImagePropertiesFromPlanFragment"] = None, - is_plan_authorized: Optional[bool] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(CustomImageFragment, self).__init__(tags=tags, **kwargs) - self.vm = vm - self.vhd = vhd - self.description = description - self.author = author - self.managed_image_id = managed_image_id - self.managed_snapshot_id = managed_snapshot_id - self.data_disk_storage_info = data_disk_storage_info - self.custom_image_plan = custom_image_plan - self.is_plan_authorized = is_plan_authorized class CustomImageList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.CustomImage] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.CustomImage] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1520,6 +1354,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.CustomImage] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(CustomImageList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1530,13 +1370,13 @@ class CustomImagePropertiesCustom(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param image_name: The image name. - :type image_name: str - :param sys_prep: Indicates whether sysprep has been run on the VHD. - :type sys_prep: bool - :param os_type: Required. The OS type of the custom image (i.e. Windows, Linux). Possible - values include: "Windows", "Linux", "None". - :type os_type: str or ~azure.mgmt.devtestlabs.models.CustomImageOsType + :ivar image_name: The image name. + :vartype image_name: str + :ivar sys_prep: Indicates whether sysprep has been run on the VHD. + :vartype sys_prep: bool + :ivar os_type: Required. The OS type of the custom image (i.e. Windows, Linux). Possible values + include: "Windows", "Linux", "None". + :vartype os_type: str or ~azure.mgmt.devtestlabs.models.CustomImageOsType """ _validation = { @@ -1557,55 +1397,32 @@ def __init__( sys_prep: Optional[bool] = None, **kwargs ): + """ + :keyword image_name: The image name. + :paramtype image_name: str + :keyword sys_prep: Indicates whether sysprep has been run on the VHD. + :paramtype sys_prep: bool + :keyword os_type: Required. The OS type of the custom image (i.e. Windows, Linux). Possible + values include: "Windows", "Linux", "None". + :paramtype os_type: str or ~azure.mgmt.devtestlabs.models.CustomImageOsType + """ super(CustomImagePropertiesCustom, self).__init__(**kwargs) self.image_name = image_name self.sys_prep = sys_prep self.os_type = os_type -class CustomImagePropertiesCustomFragment(msrest.serialization.Model): - """Properties for creating a custom image from a VHD. - - :param image_name: The image name. - :type image_name: str - :param sys_prep: Indicates whether sysprep has been run on the VHD. - :type sys_prep: bool - :param os_type: The OS type of the custom image (i.e. Windows, Linux). Possible values include: - "Windows", "Linux", "None". - :type os_type: str or ~azure.mgmt.devtestlabs.models.CustomImageOsType - """ - - _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'sys_prep': {'key': 'sysPrep', 'type': 'bool'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - } - - def __init__( - self, - *, - image_name: Optional[str] = None, - sys_prep: Optional[bool] = None, - os_type: Optional[Union[str, "CustomImageOsType"]] = None, - **kwargs - ): - super(CustomImagePropertiesCustomFragment, self).__init__(**kwargs) - self.image_name = image_name - self.sys_prep = sys_prep - self.os_type = os_type - - class CustomImagePropertiesFromPlan(msrest.serialization.Model): """Properties for plan on a custom image. - :param id: The id of the plan, equivalent to name of the plan. - :type id: str - :param publisher: The publisher for the plan from the marketplace image the custom image is + :ivar id: The id of the plan, equivalent to name of the plan. + :vartype id: str + :ivar publisher: The publisher for the plan from the marketplace image the custom image is derived from. - :type publisher: str - :param offer: The offer for the plan from the marketplace image the custom image is derived + :vartype publisher: str + :ivar offer: The offer for the plan from the marketplace image the custom image is derived from. - :type offer: str + :vartype offer: str """ _attribute_map = { @@ -1622,54 +1439,31 @@ def __init__( offer: Optional[str] = None, **kwargs ): + """ + :keyword id: The id of the plan, equivalent to name of the plan. + :paramtype id: str + :keyword publisher: The publisher for the plan from the marketplace image the custom image is + derived from. + :paramtype publisher: str + :keyword offer: The offer for the plan from the marketplace image the custom image is derived + from. + :paramtype offer: str + """ super(CustomImagePropertiesFromPlan, self).__init__(**kwargs) self.id = id self.publisher = publisher self.offer = offer -class CustomImagePropertiesFromPlanFragment(msrest.serialization.Model): - """Properties for plan on a custom image. - - :param id: The id of the plan, equivalent to name of the plan. - :type id: str - :param publisher: The publisher for the plan from the marketplace image the custom image is - derived from. - :type publisher: str - :param offer: The offer for the plan from the marketplace image the custom image is derived - from. - :type offer: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, - } - - def __init__( - self, - *, - id: Optional[str] = None, - publisher: Optional[str] = None, - offer: Optional[str] = None, - **kwargs - ): - super(CustomImagePropertiesFromPlanFragment, self).__init__(**kwargs) - self.id = id - self.publisher = publisher - self.offer = offer - - class CustomImagePropertiesFromVm(msrest.serialization.Model): """Properties for creating a custom image from a virtual machine. - :param source_vm_id: The source vm identifier. - :type source_vm_id: str - :param windows_os_info: The Windows OS information of the VM. - :type windows_os_info: ~azure.mgmt.devtestlabs.models.WindowsOsInfo - :param linux_os_info: The Linux OS information of the VM. - :type linux_os_info: ~azure.mgmt.devtestlabs.models.LinuxOsInfo + :ivar source_vm_id: The source vm identifier. + :vartype source_vm_id: str + :ivar windows_os_info: The Windows OS information of the VM. + :vartype windows_os_info: ~azure.mgmt.devtestlabs.models.WindowsOsInfo + :ivar linux_os_info: The Linux OS information of the VM. + :vartype linux_os_info: ~azure.mgmt.devtestlabs.models.LinuxOsInfo """ _attribute_map = { @@ -1686,54 +1480,31 @@ def __init__( linux_os_info: Optional["LinuxOsInfo"] = None, **kwargs ): + """ + :keyword source_vm_id: The source vm identifier. + :paramtype source_vm_id: str + :keyword windows_os_info: The Windows OS information of the VM. + :paramtype windows_os_info: ~azure.mgmt.devtestlabs.models.WindowsOsInfo + :keyword linux_os_info: The Linux OS information of the VM. + :paramtype linux_os_info: ~azure.mgmt.devtestlabs.models.LinuxOsInfo + """ super(CustomImagePropertiesFromVm, self).__init__(**kwargs) self.source_vm_id = source_vm_id self.windows_os_info = windows_os_info self.linux_os_info = linux_os_info -class CustomImagePropertiesFromVmFragment(msrest.serialization.Model): - """Properties for creating a custom image from a virtual machine. - - :param source_vm_id: The source vm identifier. - :type source_vm_id: str - :param windows_os_info: The Windows OS information of the VM. - :type windows_os_info: ~azure.mgmt.devtestlabs.models.WindowsOsInfoFragment - :param linux_os_info: The Linux OS information of the VM. - :type linux_os_info: ~azure.mgmt.devtestlabs.models.LinuxOsInfoFragment - """ - - _attribute_map = { - 'source_vm_id': {'key': 'sourceVmId', 'type': 'str'}, - 'windows_os_info': {'key': 'windowsOsInfo', 'type': 'WindowsOsInfoFragment'}, - 'linux_os_info': {'key': 'linuxOsInfo', 'type': 'LinuxOsInfoFragment'}, - } - - def __init__( - self, - *, - source_vm_id: Optional[str] = None, - windows_os_info: Optional["WindowsOsInfoFragment"] = None, - linux_os_info: Optional["LinuxOsInfoFragment"] = None, - **kwargs - ): - super(CustomImagePropertiesFromVmFragment, self).__init__(**kwargs) - self.source_vm_id = source_vm_id - self.windows_os_info = windows_os_info - self.linux_os_info = linux_os_info - - class DataDiskProperties(msrest.serialization.Model): """Request body for adding a new or existing data disk to a virtual machine. - :param attach_new_data_disk_options: Specifies options to attach a new disk to the virtual + :ivar attach_new_data_disk_options: Specifies options to attach a new disk to the virtual machine. - :type attach_new_data_disk_options: ~azure.mgmt.devtestlabs.models.AttachNewDataDiskOptions - :param existing_lab_disk_id: Specifies the existing lab disk id to attach to virtual machine. - :type existing_lab_disk_id: str - :param host_caching: Caching option for a data disk (i.e. None, ReadOnly, ReadWrite). Possible + :vartype attach_new_data_disk_options: ~azure.mgmt.devtestlabs.models.AttachNewDataDiskOptions + :ivar existing_lab_disk_id: Specifies the existing lab disk id to attach to virtual machine. + :vartype existing_lab_disk_id: str + :ivar host_caching: Caching option for a data disk (i.e. None, ReadOnly, ReadWrite). Possible values include: "None", "ReadOnly", "ReadWrite". - :type host_caching: str or ~azure.mgmt.devtestlabs.models.HostCachingOptions + :vartype host_caching: str or ~azure.mgmt.devtestlabs.models.HostCachingOptions """ _attribute_map = { @@ -1750,54 +1521,31 @@ def __init__( host_caching: Optional[Union[str, "HostCachingOptions"]] = None, **kwargs ): + """ + :keyword attach_new_data_disk_options: Specifies options to attach a new disk to the virtual + machine. + :paramtype attach_new_data_disk_options: + ~azure.mgmt.devtestlabs.models.AttachNewDataDiskOptions + :keyword existing_lab_disk_id: Specifies the existing lab disk id to attach to virtual machine. + :paramtype existing_lab_disk_id: str + :keyword host_caching: Caching option for a data disk (i.e. None, ReadOnly, ReadWrite). + Possible values include: "None", "ReadOnly", "ReadWrite". + :paramtype host_caching: str or ~azure.mgmt.devtestlabs.models.HostCachingOptions + """ super(DataDiskProperties, self).__init__(**kwargs) self.attach_new_data_disk_options = attach_new_data_disk_options self.existing_lab_disk_id = existing_lab_disk_id self.host_caching = host_caching -class DataDiskPropertiesFragment(msrest.serialization.Model): - """Request body for adding a new or existing data disk to a virtual machine. - - :param attach_new_data_disk_options: Specifies options to attach a new disk to the virtual - machine. - :type attach_new_data_disk_options: - ~azure.mgmt.devtestlabs.models.AttachNewDataDiskOptionsFragment - :param existing_lab_disk_id: Specifies the existing lab disk id to attach to virtual machine. - :type existing_lab_disk_id: str - :param host_caching: Caching option for a data disk (i.e. None, ReadOnly, ReadWrite). Possible - values include: "None", "ReadOnly", "ReadWrite". - :type host_caching: str or ~azure.mgmt.devtestlabs.models.HostCachingOptions - """ - - _attribute_map = { - 'attach_new_data_disk_options': {'key': 'attachNewDataDiskOptions', 'type': 'AttachNewDataDiskOptionsFragment'}, - 'existing_lab_disk_id': {'key': 'existingLabDiskId', 'type': 'str'}, - 'host_caching': {'key': 'hostCaching', 'type': 'str'}, - } - - def __init__( - self, - *, - attach_new_data_disk_options: Optional["AttachNewDataDiskOptionsFragment"] = None, - existing_lab_disk_id: Optional[str] = None, - host_caching: Optional[Union[str, "HostCachingOptions"]] = None, - **kwargs - ): - super(DataDiskPropertiesFragment, self).__init__(**kwargs) - self.attach_new_data_disk_options = attach_new_data_disk_options - self.existing_lab_disk_id = existing_lab_disk_id - self.host_caching = host_caching - - class DataDiskStorageTypeInfo(msrest.serialization.Model): """Storage information about the data disks present in the custom image. - :param lun: Disk Lun. - :type lun: str - :param storage_type: Disk Storage Type. Possible values include: "Standard", "Premium", + :ivar lun: Disk Lun. + :vartype lun: str + :ivar storage_type: Disk Storage Type. Possible values include: "Standard", "Premium", "StandardSSD". - :type storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType + :vartype storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType """ _attribute_map = { @@ -1812,43 +1560,23 @@ def __init__( storage_type: Optional[Union[str, "StorageType"]] = None, **kwargs ): + """ + :keyword lun: Disk Lun. + :paramtype lun: str + :keyword storage_type: Disk Storage Type. Possible values include: "Standard", "Premium", + "StandardSSD". + :paramtype storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType + """ super(DataDiskStorageTypeInfo, self).__init__(**kwargs) self.lun = lun self.storage_type = storage_type -class DataDiskStorageTypeInfoFragment(msrest.serialization.Model): - """Storage information about the data disks present in the custom image. - - :param lun: Disk Lun. - :type lun: str - :param storage_type: Disk Storage Type. Possible values include: "Standard", "Premium", - "StandardSSD". - :type storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType - """ - - _attribute_map = { - 'lun': {'key': 'lun', 'type': 'str'}, - 'storage_type': {'key': 'storageType', 'type': 'str'}, - } - - def __init__( - self, - *, - lun: Optional[str] = None, - storage_type: Optional[Union[str, "StorageType"]] = None, - **kwargs - ): - super(DataDiskStorageTypeInfoFragment, self).__init__(**kwargs) - self.lun = lun - self.storage_type = storage_type - - class DayDetails(msrest.serialization.Model): """Properties of a daily schedule. - :param time: The time of day the schedule will occur. - :type time: str + :ivar time: The time of day the schedule will occur. + :vartype time: str """ _attribute_map = { @@ -1861,36 +1589,19 @@ def __init__( time: Optional[str] = None, **kwargs ): + """ + :keyword time: The time of day the schedule will occur. + :paramtype time: str + """ super(DayDetails, self).__init__(**kwargs) self.time = time -class DayDetailsFragment(msrest.serialization.Model): - """Properties of a daily schedule. - - :param time: The time of day the schedule will occur. - :type time: str - """ - - _attribute_map = { - 'time': {'key': 'time', 'type': 'str'}, - } - - def __init__( - self, - *, - time: Optional[str] = None, - **kwargs - ): - super(DayDetailsFragment, self).__init__(**kwargs) - self.time = time - - class DetachDataDiskProperties(msrest.serialization.Model): """Request body for detaching data disk from a virtual machine. - :param existing_lab_disk_id: Specifies the disk resource ID to detach from virtual machine. - :type existing_lab_disk_id: str + :ivar existing_lab_disk_id: Specifies the disk resource ID to detach from virtual machine. + :vartype existing_lab_disk_id: str """ _attribute_map = { @@ -1903,6 +1614,10 @@ def __init__( existing_lab_disk_id: Optional[str] = None, **kwargs ): + """ + :keyword existing_lab_disk_id: Specifies the disk resource ID to detach from virtual machine. + :paramtype existing_lab_disk_id: str + """ super(DetachDataDiskProperties, self).__init__(**kwargs) self.existing_lab_disk_id = existing_lab_disk_id @@ -1910,8 +1625,8 @@ def __init__( class DetachDiskProperties(msrest.serialization.Model): """Properties of the disk to detach. - :param leased_by_lab_vm_id: The resource ID of the Lab VM to which the disk is attached. - :type leased_by_lab_vm_id: str + :ivar leased_by_lab_vm_id: The resource ID of the Lab VM to which the disk is attached. + :vartype leased_by_lab_vm_id: str """ _attribute_map = { @@ -1924,6 +1639,10 @@ def __init__( leased_by_lab_vm_id: Optional[str] = None, **kwargs ): + """ + :keyword leased_by_lab_vm_id: The resource ID of the Lab VM to which the disk is attached. + :paramtype leased_by_lab_vm_id: str + """ super(DetachDiskProperties, self).__init__(**kwargs) self.leased_by_lab_vm_id = leased_by_lab_vm_id @@ -1939,28 +1658,30 @@ class Disk(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values include: "Standard", "Premium", "StandardSSD". - :type disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType - :param disk_size_gi_b: The size of the disk in GibiBytes. - :type disk_size_gi_b: int - :param leased_by_lab_vm_id: The resource ID of the VM to which this disk is leased. - :type leased_by_lab_vm_id: str - :param disk_blob_name: When backed by a blob, the name of the VHD blob without extension. - :type disk_blob_name: str - :param disk_uri: When backed by a blob, the URI of underlying blob. - :type disk_uri: str + :vartype disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType + :ivar disk_size_gi_b: The size of the disk in Gibibytes. + :vartype disk_size_gi_b: int + :ivar leased_by_lab_vm_id: The resource ID of the VM to which this disk is leased. + :vartype leased_by_lab_vm_id: str + :ivar disk_blob_name: When backed by a blob, the name of the VHD blob without extension. + :vartype disk_blob_name: str + :ivar disk_uri: When backed by a blob, the URI of underlying blob. + :vartype disk_uri: str + :ivar storage_account_id: When backed by a blob, the storage account where the blob is. + :vartype storage_account_id: str :ivar created_date: The creation date of the disk. :vartype created_date: ~datetime.datetime - :param host_caching: The host caching policy of the disk (i.e. None, ReadOnly, ReadWrite). - :type host_caching: str - :param managed_disk_id: When backed by managed disk, this is the ID of the compute disk + :ivar host_caching: The host caching policy of the disk (i.e. None, ReadOnly, ReadWrite). + :vartype host_caching: str + :ivar managed_disk_id: When backed by managed disk, this is the ID of the compute disk resource. - :type managed_disk_id: str + :vartype managed_disk_id: str :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -1987,6 +1708,7 @@ class Disk(Resource): 'leased_by_lab_vm_id': {'key': 'properties.leasedByLabVmId', 'type': 'str'}, 'disk_blob_name': {'key': 'properties.diskBlobName', 'type': 'str'}, 'disk_uri': {'key': 'properties.diskUri', 'type': 'str'}, + 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, 'host_caching': {'key': 'properties.hostCaching', 'type': 'str'}, 'managed_disk_id': {'key': 'properties.managedDiskId', 'type': 'str'}, @@ -2004,16 +1726,42 @@ def __init__( leased_by_lab_vm_id: Optional[str] = None, disk_blob_name: Optional[str] = None, disk_uri: Optional[str] = None, + storage_account_id: Optional[str] = None, host_caching: Optional[str] = None, managed_disk_id: Optional[str] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values + include: "Standard", "Premium", "StandardSSD". + :paramtype disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType + :keyword disk_size_gi_b: The size of the disk in Gibibytes. + :paramtype disk_size_gi_b: int + :keyword leased_by_lab_vm_id: The resource ID of the VM to which this disk is leased. + :paramtype leased_by_lab_vm_id: str + :keyword disk_blob_name: When backed by a blob, the name of the VHD blob without extension. + :paramtype disk_blob_name: str + :keyword disk_uri: When backed by a blob, the URI of underlying blob. + :paramtype disk_uri: str + :keyword storage_account_id: When backed by a blob, the storage account where the blob is. + :paramtype storage_account_id: str + :keyword host_caching: The host caching policy of the disk (i.e. None, ReadOnly, ReadWrite). + :paramtype host_caching: str + :keyword managed_disk_id: When backed by managed disk, this is the ID of the compute disk + resource. + :paramtype managed_disk_id: str + """ super(Disk, self).__init__(location=location, tags=tags, **kwargs) self.disk_type = disk_type self.disk_size_gi_b = disk_size_gi_b self.leased_by_lab_vm_id = leased_by_lab_vm_id self.disk_blob_name = disk_blob_name self.disk_uri = disk_uri + self.storage_account_id = storage_account_id self.created_date = None self.host_caching = host_caching self.managed_disk_id = managed_disk_id @@ -2024,67 +1772,34 @@ def __init__( class DiskFragment(UpdateResource): """A Disk. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param disk_type: The storage type for the disk (i.e. Standard, Premium). Possible values - include: "Standard", "Premium", "StandardSSD". - :type disk_type: str or ~azure.mgmt.devtestlabs.models.StorageType - :param disk_size_gi_b: The size of the disk in GibiBytes. - :type disk_size_gi_b: int - :param leased_by_lab_vm_id: The resource ID of the VM to which this disk is leased. - :type leased_by_lab_vm_id: str - :param disk_blob_name: When backed by a blob, the name of the VHD blob without extension. - :type disk_blob_name: str - :param disk_uri: When backed by a blob, the URI of underlying blob. - :type disk_uri: str - :param host_caching: The host caching policy of the disk (i.e. None, ReadOnly, ReadWrite). - :type host_caching: str - :param managed_disk_id: When backed by managed disk, this is the ID of the compute disk - resource. - :type managed_disk_id: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'disk_type': {'key': 'properties.diskType', 'type': 'str'}, - 'disk_size_gi_b': {'key': 'properties.diskSizeGiB', 'type': 'int'}, - 'leased_by_lab_vm_id': {'key': 'properties.leasedByLabVmId', 'type': 'str'}, - 'disk_blob_name': {'key': 'properties.diskBlobName', 'type': 'str'}, - 'disk_uri': {'key': 'properties.diskUri', 'type': 'str'}, - 'host_caching': {'key': 'properties.hostCaching', 'type': 'str'}, - 'managed_disk_id': {'key': 'properties.managedDiskId', 'type': 'str'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - disk_type: Optional[Union[str, "StorageType"]] = None, - disk_size_gi_b: Optional[int] = None, - leased_by_lab_vm_id: Optional[str] = None, - disk_blob_name: Optional[str] = None, - disk_uri: Optional[str] = None, - host_caching: Optional[str] = None, - managed_disk_id: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(DiskFragment, self).__init__(tags=tags, **kwargs) - self.disk_type = disk_type - self.disk_size_gi_b = disk_size_gi_b - self.leased_by_lab_vm_id = leased_by_lab_vm_id - self.disk_blob_name = disk_blob_name - self.disk_uri = disk_uri - self.host_caching = host_caching - self.managed_disk_id = managed_disk_id class DiskList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Disk] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.Disk] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2099,6 +1814,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.Disk] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(DiskList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2115,15 +1836,15 @@ class DtlEnvironment(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param deployment_properties: The deployment properties of the environment. - :type deployment_properties: ~azure.mgmt.devtestlabs.models.EnvironmentDeploymentProperties - :param arm_template_display_name: The display name of the Azure Resource Manager template that + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar deployment_properties: The deployment properties of the environment. + :vartype deployment_properties: ~azure.mgmt.devtestlabs.models.EnvironmentDeploymentProperties + :ivar arm_template_display_name: The display name of the Azure Resource Manager template that produced the environment. - :type arm_template_display_name: str + :vartype arm_template_display_name: str :ivar resource_group_id: The identifier of the resource group containing the environment's resources. :vartype resource_group_id: str @@ -2168,6 +1889,18 @@ def __init__( arm_template_display_name: Optional[str] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword deployment_properties: The deployment properties of the environment. + :paramtype deployment_properties: + ~azure.mgmt.devtestlabs.models.EnvironmentDeploymentProperties + :keyword arm_template_display_name: The display name of the Azure Resource Manager template + that produced the environment. + :paramtype arm_template_display_name: str + """ super(DtlEnvironment, self).__init__(location=location, tags=tags, **kwargs) self.deployment_properties = deployment_properties self.arm_template_display_name = arm_template_display_name @@ -2180,42 +1913,34 @@ def __init__( class DtlEnvironmentFragment(UpdateResource): """An environment, which is essentially an ARM template deployment. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param deployment_properties: The deployment properties of the environment. - :type deployment_properties: - ~azure.mgmt.devtestlabs.models.EnvironmentDeploymentPropertiesFragment - :param arm_template_display_name: The display name of the Azure Resource Manager template that - produced the environment. - :type arm_template_display_name: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'deployment_properties': {'key': 'properties.deploymentProperties', 'type': 'EnvironmentDeploymentPropertiesFragment'}, - 'arm_template_display_name': {'key': 'properties.armTemplateDisplayName', 'type': 'str'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - deployment_properties: Optional["EnvironmentDeploymentPropertiesFragment"] = None, - arm_template_display_name: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(DtlEnvironmentFragment, self).__init__(tags=tags, **kwargs) - self.deployment_properties = deployment_properties - self.arm_template_display_name = arm_template_display_name class DtlEnvironmentList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.DtlEnvironment] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.DtlEnvironment] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2230,6 +1955,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.DtlEnvironment] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(DtlEnvironmentList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2238,10 +1969,10 @@ def __init__( class EnvironmentDeploymentProperties(msrest.serialization.Model): """Properties of an environment deployment. - :param arm_template_id: The Azure Resource Manager template's identifier. - :type arm_template_id: str - :param parameters: The parameters of the Azure Resource Manager template. - :type parameters: list[~azure.mgmt.devtestlabs.models.ArmTemplateParameterProperties] + :ivar arm_template_id: The Azure Resource Manager template's identifier. + :vartype arm_template_id: str + :ivar parameters: The parameters of the Azure Resource Manager template. + :vartype parameters: list[~azure.mgmt.devtestlabs.models.ArmTemplateParameterProperties] """ _attribute_map = { @@ -2256,48 +1987,28 @@ def __init__( parameters: Optional[List["ArmTemplateParameterProperties"]] = None, **kwargs ): + """ + :keyword arm_template_id: The Azure Resource Manager template's identifier. + :paramtype arm_template_id: str + :keyword parameters: The parameters of the Azure Resource Manager template. + :paramtype parameters: list[~azure.mgmt.devtestlabs.models.ArmTemplateParameterProperties] + """ super(EnvironmentDeploymentProperties, self).__init__(**kwargs) self.arm_template_id = arm_template_id self.parameters = parameters -class EnvironmentDeploymentPropertiesFragment(msrest.serialization.Model): - """Properties of an environment deployment. - - :param arm_template_id: The Azure Resource Manager template's identifier. - :type arm_template_id: str - :param parameters: The parameters of the Azure Resource Manager template. - :type parameters: list[~azure.mgmt.devtestlabs.models.ArmTemplateParameterPropertiesFragment] - """ - - _attribute_map = { - 'arm_template_id': {'key': 'armTemplateId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ArmTemplateParameterPropertiesFragment]'}, - } - - def __init__( - self, - *, - arm_template_id: Optional[str] = None, - parameters: Optional[List["ArmTemplateParameterPropertiesFragment"]] = None, - **kwargs - ): - super(EnvironmentDeploymentPropertiesFragment, self).__init__(**kwargs) - self.arm_template_id = arm_template_id - self.parameters = parameters - - class EvaluatePoliciesProperties(msrest.serialization.Model): """Properties for evaluating a policy set. - :param fact_name: The fact name. - :type fact_name: str - :param fact_data: The fact data. - :type fact_data: str - :param value_offset: The value offset. - :type value_offset: str - :param user_object_id: The user for which policies will be evaluated. - :type user_object_id: str + :ivar fact_name: The fact name. + :vartype fact_name: str + :ivar fact_data: The fact data. + :vartype fact_data: str + :ivar value_offset: The value offset. + :vartype value_offset: str + :ivar user_object_id: The user for which policies will be evaluated. + :vartype user_object_id: str """ _attribute_map = { @@ -2316,6 +2027,16 @@ def __init__( user_object_id: Optional[str] = None, **kwargs ): + """ + :keyword fact_name: The fact name. + :paramtype fact_name: str + :keyword fact_data: The fact data. + :paramtype fact_data: str + :keyword value_offset: The value offset. + :paramtype value_offset: str + :keyword user_object_id: The user for which policies will be evaluated. + :paramtype user_object_id: str + """ super(EvaluatePoliciesProperties, self).__init__(**kwargs) self.fact_name = fact_name self.fact_data = fact_data @@ -2326,8 +2047,8 @@ def __init__( class EvaluatePoliciesRequest(msrest.serialization.Model): """Request body for evaluating a policy set. - :param policies: Policies to evaluate. - :type policies: list[~azure.mgmt.devtestlabs.models.EvaluatePoliciesProperties] + :ivar policies: Policies to evaluate. + :vartype policies: list[~azure.mgmt.devtestlabs.models.EvaluatePoliciesProperties] """ _attribute_map = { @@ -2340,6 +2061,10 @@ def __init__( policies: Optional[List["EvaluatePoliciesProperties"]] = None, **kwargs ): + """ + :keyword policies: Policies to evaluate. + :paramtype policies: list[~azure.mgmt.devtestlabs.models.EvaluatePoliciesProperties] + """ super(EvaluatePoliciesRequest, self).__init__(**kwargs) self.policies = policies @@ -2347,8 +2072,8 @@ def __init__( class EvaluatePoliciesResponse(msrest.serialization.Model): """Response body for evaluating a policy set. - :param results: Results of evaluating a policy set. - :type results: list[~azure.mgmt.devtestlabs.models.PolicySetResult] + :ivar results: Results of evaluating a policy set. + :vartype results: list[~azure.mgmt.devtestlabs.models.PolicySetResult] """ _attribute_map = { @@ -2361,6 +2086,10 @@ def __init__( results: Optional[List["PolicySetResult"]] = None, **kwargs ): + """ + :keyword results: Results of evaluating a policy set. + :paramtype results: list[~azure.mgmt.devtestlabs.models.PolicySetResult] + """ super(EvaluatePoliciesResponse, self).__init__(**kwargs) self.results = results @@ -2368,9 +2097,9 @@ def __init__( class Event(msrest.serialization.Model): """An event to be notified for. - :param event_name: The event type for which this notification is enabled (i.e. AutoShutdown, + :ivar event_name: The event type for which this notification is enabled (i.e. AutoShutdown, Cost). Possible values include: "AutoShutdown", "Cost". - :type event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType + :vartype event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType """ _attribute_map = { @@ -2383,41 +2112,24 @@ def __init__( event_name: Optional[Union[str, "NotificationChannelEventType"]] = None, **kwargs ): + """ + :keyword event_name: The event type for which this notification is enabled (i.e. AutoShutdown, + Cost). Possible values include: "AutoShutdown", "Cost". + :paramtype event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType + """ super(Event, self).__init__(**kwargs) self.event_name = event_name -class EventFragment(msrest.serialization.Model): - """An event to be notified for. - - :param event_name: The event type for which this notification is enabled (i.e. AutoShutdown, - Cost). Possible values include: "AutoShutdown", "Cost". - :type event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType - """ - - _attribute_map = { - 'event_name': {'key': 'eventName', 'type': 'str'}, - } - - def __init__( - self, - *, - event_name: Optional[Union[str, "NotificationChannelEventType"]] = None, - **kwargs - ): - super(EventFragment, self).__init__(**kwargs) - self.event_name = event_name - - class ExportResourceUsageParameters(msrest.serialization.Model): """The parameters of the export operation. - :param blob_storage_absolute_sas_uri: The blob storage absolute sas uri with write permission - to the container which the usage data needs to be uploaded to. - :type blob_storage_absolute_sas_uri: str - :param usage_start_date: The start time of the usage. If not provided, usage will be reported + :ivar blob_storage_absolute_sas_uri: The blob storage absolute sas uri with write permission to + the container which the usage data needs to be uploaded to. + :vartype blob_storage_absolute_sas_uri: str + :ivar usage_start_date: The start time of the usage. If not provided, usage will be reported since the beginning of data collection. - :type usage_start_date: ~datetime.datetime + :vartype usage_start_date: ~datetime.datetime """ _attribute_map = { @@ -2432,6 +2144,14 @@ def __init__( usage_start_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword blob_storage_absolute_sas_uri: The blob storage absolute sas uri with write permission + to the container which the usage data needs to be uploaded to. + :paramtype blob_storage_absolute_sas_uri: str + :keyword usage_start_date: The start time of the usage. If not provided, usage will be reported + since the beginning of data collection. + :paramtype usage_start_date: ~datetime.datetime + """ super(ExportResourceUsageParameters, self).__init__(**kwargs) self.blob_storage_absolute_sas_uri = blob_storage_absolute_sas_uri self.usage_start_date = usage_start_date @@ -2440,10 +2160,10 @@ def __init__( class ExternalSubnet(msrest.serialization.Model): """Subnet information as returned by the Microsoft.Network API. - :param id: Gets or sets the identifier. - :type id: str - :param name: Gets or sets the name. - :type name: str + :ivar id: Gets or sets the identifier. + :vartype id: str + :ivar name: Gets or sets the name. + :vartype name: str """ _attribute_map = { @@ -2458,37 +2178,17 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword id: Gets or sets the identifier. + :paramtype id: str + :keyword name: Gets or sets the name. + :paramtype name: str + """ super(ExternalSubnet, self).__init__(**kwargs) self.id = id self.name = name -class ExternalSubnetFragment(msrest.serialization.Model): - """Subnet information as returned by the Microsoft.Network API. - - :param id: Gets or sets the identifier. - :type id: str - :param name: Gets or sets the name. - :type 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 - ): - super(ExternalSubnetFragment, self).__init__(**kwargs) - self.id = id - self.name = name - - class Formula(Resource): """A formula for creating a VM, specifying an image base and other parameters. @@ -2500,22 +2200,22 @@ class Formula(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param description: The description of the formula. - :type description: str - :param author: The author of the formula. - :type author: str - :param os_type: The OS type of the formula. - :type os_type: str + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar description: The description of the formula. + :vartype description: str + :ivar author: The author of the formula. + :vartype author: str + :ivar os_type: The OS type of the formula. + :vartype os_type: str :ivar creation_date: The creation date of the formula. :vartype creation_date: ~datetime.datetime - :param formula_content: The content of the formula. - :type formula_content: ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameter - :param vm: Information about a VM from which a formula is to be created. - :type vm: ~azure.mgmt.devtestlabs.models.FormulaPropertiesFromVm + :ivar formula_content: The content of the formula. + :vartype formula_content: ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameter + :ivar vm: Information about a VM from which a formula is to be created. + :vartype vm: ~azure.mgmt.devtestlabs.models.FormulaPropertiesFromVm :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -2526,6 +2226,7 @@ class Formula(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'author': {'readonly': True}, 'creation_date': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'unique_identifier': {'readonly': True}, @@ -2553,15 +2254,28 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - author: Optional[str] = None, os_type: Optional[str] = None, formula_content: Optional["LabVirtualMachineCreationParameter"] = None, vm: Optional["FormulaPropertiesFromVm"] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword description: The description of the formula. + :paramtype description: str + :keyword os_type: The OS type of the formula. + :paramtype os_type: str + :keyword formula_content: The content of the formula. + :paramtype formula_content: ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameter + :keyword vm: Information about a VM from which a formula is to be created. + :paramtype vm: ~azure.mgmt.devtestlabs.models.FormulaPropertiesFromVm + """ super(Formula, self).__init__(location=location, tags=tags, **kwargs) self.description = description - self.author = author + self.author = None self.os_type = os_type self.creation_date = None self.formula_content = formula_content @@ -2573,56 +2287,34 @@ def __init__( class FormulaFragment(UpdateResource): """A formula for creating a VM, specifying an image base and other parameters. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param description: The description of the formula. - :type description: str - :param author: The author of the formula. - :type author: str - :param os_type: The OS type of the formula. - :type os_type: str - :param formula_content: The content of the formula. - :type formula_content: - ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameterFragment - :param vm: Information about a VM from which a formula is to be created. - :type vm: ~azure.mgmt.devtestlabs.models.FormulaPropertiesFromVmFragment + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'formula_content': {'key': 'properties.formulaContent', 'type': 'LabVirtualMachineCreationParameterFragment'}, - 'vm': {'key': 'properties.vm', 'type': 'FormulaPropertiesFromVmFragment'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - author: Optional[str] = None, - os_type: Optional[str] = None, - formula_content: Optional["LabVirtualMachineCreationParameterFragment"] = None, - vm: Optional["FormulaPropertiesFromVmFragment"] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(FormulaFragment, self).__init__(tags=tags, **kwargs) - self.description = description - self.author = author - self.os_type = os_type - self.formula_content = formula_content - self.vm = vm class FormulaList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Formula] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.Formula] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2637,6 +2329,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.Formula] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(FormulaList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2645,8 +2343,8 @@ def __init__( class FormulaPropertiesFromVm(msrest.serialization.Model): """Information about a VM from which a formula is to be created. - :param lab_vm_id: The identifier of the VM from which a formula is to be created. - :type lab_vm_id: str + :ivar lab_vm_id: The identifier of the VM from which a formula is to be created. + :vartype lab_vm_id: str """ _attribute_map = { @@ -2659,31 +2357,14 @@ def __init__( lab_vm_id: Optional[str] = None, **kwargs ): + """ + :keyword lab_vm_id: The identifier of the VM from which a formula is to be created. + :paramtype lab_vm_id: str + """ super(FormulaPropertiesFromVm, self).__init__(**kwargs) self.lab_vm_id = lab_vm_id -class FormulaPropertiesFromVmFragment(msrest.serialization.Model): - """Information about a VM from which a formula is to be created. - - :param lab_vm_id: The identifier of the VM from which a formula is to be created. - :type lab_vm_id: str - """ - - _attribute_map = { - 'lab_vm_id': {'key': 'labVmId', 'type': 'str'}, - } - - def __init__( - self, - *, - lab_vm_id: Optional[str] = None, - **kwargs - ): - super(FormulaPropertiesFromVmFragment, self).__init__(**kwargs) - self.lab_vm_id = lab_vm_id - - class GalleryImage(Resource): """A gallery image. @@ -2695,27 +2376,27 @@ class GalleryImage(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param author: The author of the gallery image. - :type author: str + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar author: The author of the gallery image. + :vartype author: str :ivar created_date: The creation date of the gallery image. :vartype created_date: ~datetime.datetime - :param description: The description of the gallery image. - :type description: str - :param image_reference: The image reference of the gallery image. - :type image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference - :param icon: The icon of the gallery image. - :type icon: str - :param enabled: Indicates whether this gallery image is enabled. - :type enabled: bool - :param plan_id: The third party plan that applies to this image. - :type plan_id: str - :param is_plan_authorized: Indicates if the plan has been authorized for programmatic + :ivar description: The description of the gallery image. + :vartype description: str + :ivar image_reference: The image reference of the gallery image. + :vartype image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference + :ivar icon: The icon of the gallery image. + :vartype icon: str + :ivar enabled: Indicates whether this gallery image is enabled. + :vartype enabled: bool + :ivar plan_id: The third party plan that applies to this image. + :vartype plan_id: str + :ivar is_plan_authorized: Indicates if the plan has been authorized for programmatic deployment. - :type is_plan_authorized: bool + :vartype is_plan_authorized: bool """ _validation = { @@ -2755,6 +2436,27 @@ def __init__( is_plan_authorized: Optional[bool] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword author: The author of the gallery image. + :paramtype author: str + :keyword description: The description of the gallery image. + :paramtype description: str + :keyword image_reference: The image reference of the gallery image. + :paramtype image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference + :keyword icon: The icon of the gallery image. + :paramtype icon: str + :keyword enabled: Indicates whether this gallery image is enabled. + :paramtype enabled: bool + :keyword plan_id: The third party plan that applies to this image. + :paramtype plan_id: str + :keyword is_plan_authorized: Indicates if the plan has been authorized for programmatic + deployment. + :paramtype is_plan_authorized: bool + """ super(GalleryImage, self).__init__(location=location, tags=tags, **kwargs) self.author = author self.created_date = None @@ -2769,10 +2471,10 @@ def __init__( class GalleryImageList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.GalleryImage] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.GalleryImage] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2787,6 +2489,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.GalleryImage] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(GalleryImageList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2795,16 +2503,16 @@ def __init__( class GalleryImageReference(msrest.serialization.Model): """The reference information for an Azure Marketplace image. - :param offer: The offer of the gallery image. - :type offer: str - :param publisher: The publisher of the gallery image. - :type publisher: str - :param sku: The SKU of the gallery image. - :type sku: str - :param os_type: The OS type of the gallery image. - :type os_type: str - :param version: The version of the gallery image. - :type version: str + :ivar offer: The offer of the gallery image. + :vartype offer: str + :ivar publisher: The publisher of the gallery image. + :vartype publisher: str + :ivar sku: The SKU of the gallery image. + :vartype sku: str + :ivar os_type: The OS type of the gallery image. + :vartype os_type: str + :ivar version: The version of the gallery image. + :vartype version: str """ _attribute_map = { @@ -2825,6 +2533,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword offer: The offer of the gallery image. + :paramtype offer: str + :keyword publisher: The publisher of the gallery image. + :paramtype publisher: str + :keyword sku: The SKU of the gallery image. + :paramtype sku: str + :keyword os_type: The OS type of the gallery image. + :paramtype os_type: str + :keyword version: The version of the gallery image. + :paramtype version: str + """ super(GalleryImageReference, self).__init__(**kwargs) self.offer = offer self.publisher = publisher @@ -2833,60 +2553,19 @@ def __init__( self.version = version -class GalleryImageReferenceFragment(msrest.serialization.Model): - """The reference information for an Azure Marketplace image. - - :param offer: The offer of the gallery image. - :type offer: str - :param publisher: The publisher of the gallery image. - :type publisher: str - :param sku: The SKU of the gallery image. - :type sku: str - :param os_type: The OS type of the gallery image. - :type os_type: str - :param version: The version of the gallery image. - :type version: str - """ - - _attribute_map = { - 'offer': {'key': 'offer', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - *, - offer: Optional[str] = None, - publisher: Optional[str] = None, - sku: Optional[str] = None, - os_type: Optional[str] = None, - version: Optional[str] = None, - **kwargs - ): - super(GalleryImageReferenceFragment, self).__init__(**kwargs) - self.offer = offer - self.publisher = publisher - self.sku = sku - self.os_type = os_type - self.version = version - - class GenerateArmTemplateRequest(msrest.serialization.Model): """Parameters for generating an ARM template for deploying artifacts. - :param virtual_machine_name: The resource name of the virtual machine. - :type virtual_machine_name: str - :param parameters: The parameters of the ARM template. - :type parameters: list[~azure.mgmt.devtestlabs.models.ParameterInfo] - :param location: The location of the virtual machine. - :type location: str - :param file_upload_options: Options for uploading the files for the artifact. + :ivar virtual_machine_name: The resource name of the virtual machine. + :vartype virtual_machine_name: str + :ivar parameters: The parameters of the ARM template. + :vartype parameters: list[~azure.mgmt.devtestlabs.models.ParameterInfo] + :ivar location: The location of the virtual machine. + :vartype location: str + :ivar file_upload_options: Options for uploading the files for the artifact. UploadFilesAndGenerateSasTokens is the default value. Possible values include: "UploadFilesAndGenerateSasTokens", "None". - :type file_upload_options: str or ~azure.mgmt.devtestlabs.models.FileUploadOptions + :vartype file_upload_options: str or ~azure.mgmt.devtestlabs.models.FileUploadOptions """ _attribute_map = { @@ -2905,6 +2584,18 @@ def __init__( file_upload_options: Optional[Union[str, "FileUploadOptions"]] = None, **kwargs ): + """ + :keyword virtual_machine_name: The resource name of the virtual machine. + :paramtype virtual_machine_name: str + :keyword parameters: The parameters of the ARM template. + :paramtype parameters: list[~azure.mgmt.devtestlabs.models.ParameterInfo] + :keyword location: The location of the virtual machine. + :paramtype location: str + :keyword file_upload_options: Options for uploading the files for the artifact. + UploadFilesAndGenerateSasTokens is the default value. Possible values include: + "UploadFilesAndGenerateSasTokens", "None". + :paramtype file_upload_options: str or ~azure.mgmt.devtestlabs.models.FileUploadOptions + """ super(GenerateArmTemplateRequest, self).__init__(**kwargs) self.virtual_machine_name = virtual_machine_name self.parameters = parameters @@ -2915,8 +2606,8 @@ def __init__( class GenerateUploadUriParameter(msrest.serialization.Model): """Properties for generating an upload URI. - :param blob_name: The blob name of the upload URI. - :type blob_name: str + :ivar blob_name: The blob name of the upload URI. + :vartype blob_name: str """ _attribute_map = { @@ -2929,6 +2620,10 @@ def __init__( blob_name: Optional[str] = None, **kwargs ): + """ + :keyword blob_name: The blob name of the upload URI. + :paramtype blob_name: str + """ super(GenerateUploadUriParameter, self).__init__(**kwargs) self.blob_name = blob_name @@ -2936,8 +2631,8 @@ def __init__( class GenerateUploadUriResponse(msrest.serialization.Model): """Response body for generating an upload URI. - :param upload_uri: The upload URI for the VHD. - :type upload_uri: str + :ivar upload_uri: The upload URI for the VHD. + :vartype upload_uri: str """ _attribute_map = { @@ -2950,6 +2645,10 @@ def __init__( upload_uri: Optional[str] = None, **kwargs ): + """ + :keyword upload_uri: The upload URI for the VHD. + :paramtype upload_uri: str + """ super(GenerateUploadUriResponse, self).__init__(**kwargs) self.upload_uri = upload_uri @@ -2957,8 +2656,8 @@ def __init__( class HourDetails(msrest.serialization.Model): """Properties of an hourly schedule. - :param minute: Minutes of the hour the schedule will run. - :type minute: int + :ivar minute: Minutes of the hour the schedule will run. + :vartype minute: int """ _attribute_map = { @@ -2971,42 +2670,26 @@ def __init__( minute: Optional[int] = None, **kwargs ): + """ + :keyword minute: Minutes of the hour the schedule will run. + :paramtype minute: int + """ super(HourDetails, self).__init__(**kwargs) self.minute = minute -class HourDetailsFragment(msrest.serialization.Model): - """Properties of an hourly schedule. - - :param minute: Minutes of the hour the schedule will run. - :type minute: int - """ - - _attribute_map = { - 'minute': {'key': 'minute', 'type': 'int'}, - } - - def __init__( - self, - *, - minute: Optional[int] = None, - **kwargs - ): - super(HourDetailsFragment, self).__init__(**kwargs) - self.minute = minute - - class IdentityProperties(msrest.serialization.Model): """Properties of a managed identity. - :param type: Managed identity. - :type type: str - :param principal_id: The principal id of resource identity. - :type principal_id: str - :param tenant_id: The tenant identifier of resource. - :type tenant_id: str - :param client_secret_url: The client secret URL of the identity. - :type client_secret_url: str + :ivar type: Managed identity. Possible values include: "None", "SystemAssigned", + "UserAssigned", "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.devtestlabs.models.ManagedIdentityType + :ivar principal_id: The principal id of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant identifier of resource. + :vartype tenant_id: str + :ivar client_secret_url: The client secret URL of the identity. + :vartype client_secret_url: str """ _attribute_map = { @@ -3019,12 +2702,23 @@ class IdentityProperties(msrest.serialization.Model): def __init__( self, *, - type: Optional[str] = None, + type: Optional[Union[str, "ManagedIdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, client_secret_url: Optional[str] = None, **kwargs ): + """ + :keyword type: Managed identity. Possible values include: "None", "SystemAssigned", + "UserAssigned", "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.devtestlabs.models.ManagedIdentityType + :keyword principal_id: The principal id of resource identity. + :paramtype principal_id: str + :keyword tenant_id: The tenant identifier of resource. + :paramtype tenant_id: str + :keyword client_secret_url: The client secret URL of the identity. + :paramtype client_secret_url: str + """ super(IdentityProperties, self).__init__(**kwargs) self.type = type self.principal_id = principal_id @@ -3035,12 +2729,11 @@ def __init__( class ImportLabVirtualMachineRequest(msrest.serialization.Model): """This represents the payload required to import a virtual machine from a different lab into the current one. - :param source_virtual_machine_resource_id: The full resource ID of the virtual machine to be + :ivar source_virtual_machine_resource_id: The full resource ID of the virtual machine to be imported. - :type source_virtual_machine_resource_id: str - :param destination_virtual_machine_name: The name of the virtual machine in the destination - lab. - :type destination_virtual_machine_name: str + :vartype source_virtual_machine_resource_id: str + :ivar destination_virtual_machine_name: The name of the virtual machine in the destination lab. + :vartype destination_virtual_machine_name: str """ _attribute_map = { @@ -3055,6 +2748,14 @@ def __init__( destination_virtual_machine_name: Optional[str] = None, **kwargs ): + """ + :keyword source_virtual_machine_resource_id: The full resource ID of the virtual machine to be + imported. + :paramtype source_virtual_machine_resource_id: str + :keyword destination_virtual_machine_name: The name of the virtual machine in the destination + lab. + :paramtype destination_virtual_machine_name: str + """ super(ImportLabVirtualMachineRequest, self).__init__(**kwargs) self.source_virtual_machine_resource_id = source_virtual_machine_resource_id self.destination_virtual_machine_name = destination_virtual_machine_name @@ -3063,14 +2764,14 @@ def __init__( class InboundNatRule(msrest.serialization.Model): """A rule for NAT - exposing a VM's port (backendPort) on the public IP address using a load balancer. - :param transport_protocol: The transport protocol for the endpoint. Possible values include: + :ivar transport_protocol: The transport protocol for the endpoint. Possible values include: "Tcp", "Udp". - :type transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol - :param frontend_port: The external endpoint port of the inbound connection. Possible values + :vartype transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol + :ivar frontend_port: The external endpoint port of the inbound connection. Possible values range between 1 and 65535, inclusive. If unspecified, a value will be allocated automatically. - :type frontend_port: int - :param backend_port: The port to which the external traffic will be redirected. - :type backend_port: int + :vartype frontend_port: int + :ivar backend_port: The port to which the external traffic will be redirected. + :vartype backend_port: int """ _attribute_map = { @@ -3087,45 +2788,22 @@ def __init__( backend_port: Optional[int] = None, **kwargs ): + """ + :keyword transport_protocol: The transport protocol for the endpoint. Possible values include: + "Tcp", "Udp". + :paramtype transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol + :keyword frontend_port: The external endpoint port of the inbound connection. Possible values + range between 1 and 65535, inclusive. If unspecified, a value will be allocated automatically. + :paramtype frontend_port: int + :keyword backend_port: The port to which the external traffic will be redirected. + :paramtype backend_port: int + """ super(InboundNatRule, self).__init__(**kwargs) self.transport_protocol = transport_protocol self.frontend_port = frontend_port self.backend_port = backend_port -class InboundNatRuleFragment(msrest.serialization.Model): - """A rule for NAT - exposing a VM's port (backendPort) on the public IP address using a load balancer. - - :param transport_protocol: The transport protocol for the endpoint. Possible values include: - "Tcp", "Udp". - :type transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol - :param frontend_port: The external endpoint port of the inbound connection. Possible values - range between 1 and 65535, inclusive. If unspecified, a value will be allocated automatically. - :type frontend_port: int - :param backend_port: The port to which the external traffic will be redirected. - :type backend_port: int - """ - - _attribute_map = { - 'transport_protocol': {'key': 'transportProtocol', 'type': 'str'}, - 'frontend_port': {'key': 'frontendPort', 'type': 'int'}, - 'backend_port': {'key': 'backendPort', 'type': 'int'}, - } - - def __init__( - self, - *, - transport_protocol: Optional[Union[str, "TransportProtocol"]] = None, - frontend_port: Optional[int] = None, - backend_port: Optional[int] = None, - **kwargs - ): - super(InboundNatRuleFragment, self).__init__(**kwargs) - self.transport_protocol = transport_protocol - self.frontend_port = frontend_port - self.backend_port = backend_port - - class Lab(Resource): """A lab. @@ -3137,10 +2815,10 @@ class Lab(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] :ivar default_storage_account: The lab's default storage account. :vartype default_storage_account: str :ivar default_premium_storage_account: The lab's default premium storage account. @@ -3151,31 +2829,31 @@ class Lab(Resource): :vartype premium_data_disk_storage_account: str :ivar vault_name: The lab's Key vault. :vartype vault_name: str - :param lab_storage_type: Type of storage used by the lab. It can be either Premium or Standard. + :ivar lab_storage_type: Type of storage used by the lab. It can be either Premium or Standard. Default is Premium. Possible values include: "Standard", "Premium", "StandardSSD". - :type lab_storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType - :param mandatory_artifacts_resource_ids_linux: The ordered list of artifact resource IDs that + :vartype lab_storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType + :ivar mandatory_artifacts_resource_ids_linux: The ordered list of artifact resource IDs that should be applied on all Linux VM creations by default, prior to the artifacts specified by the user. - :type mandatory_artifacts_resource_ids_linux: list[str] - :param mandatory_artifacts_resource_ids_windows: The ordered list of artifact resource IDs that + :vartype mandatory_artifacts_resource_ids_linux: list[str] + :ivar mandatory_artifacts_resource_ids_windows: The ordered list of artifact resource IDs that should be applied on all Windows VM creations by default, prior to the artifacts specified by the user. - :type mandatory_artifacts_resource_ids_windows: list[str] + :vartype mandatory_artifacts_resource_ids_windows: list[str] :ivar created_date: The creation date of the lab. :vartype created_date: ~datetime.datetime - :param premium_data_disks: The setting to enable usage of premium data disks. + :ivar premium_data_disks: The setting to enable usage of premium data disks. When its value is 'Enabled', creation of standard or premium data disks is allowed. When its value is 'Disabled', only creation of standard data disks is allowed. Possible values include: "Disabled", "Enabled". - :type premium_data_disks: str or ~azure.mgmt.devtestlabs.models.PremiumDataDisk - :param environment_permission: The access rights to be granted to the user when provisioning an + :vartype premium_data_disks: str or ~azure.mgmt.devtestlabs.models.PremiumDataDisk + :ivar environment_permission: The access rights to be granted to the user when provisioning an environment. Possible values include: "Reader", "Contributor". - :type environment_permission: str or ~azure.mgmt.devtestlabs.models.EnvironmentPermission - :param announcement: The properties of any lab announcement associated with this lab. - :type announcement: ~azure.mgmt.devtestlabs.models.LabAnnouncementProperties - :param support: The properties of any lab support message associated with this lab. - :type support: ~azure.mgmt.devtestlabs.models.LabSupportProperties + :vartype environment_permission: str or ~azure.mgmt.devtestlabs.models.EnvironmentPermission + :ivar announcement: The properties of any lab announcement associated with this lab. + :vartype announcement: ~azure.mgmt.devtestlabs.models.LabAnnouncementProperties + :ivar support: The properties of any lab support message associated with this lab. + :vartype support: ~azure.mgmt.devtestlabs.models.LabSupportProperties :ivar vm_creation_resource_group: The resource group in which all new lab virtual machines will be created. To let DevTest Labs manage resource group creation, set this value to null. :vartype vm_creation_resource_group: str @@ -3186,8 +2864,8 @@ class Lab(Resource): :ivar network_security_group_id: The Network Security Group attached to the lab VMs Network interfaces to restrict open ports. :vartype network_security_group_id: str - :param extended_properties: Extended properties of the lab used for experimental features. - :type extended_properties: dict[str, str] + :ivar extended_properties: Extended properties of the lab used for experimental features. + :vartype extended_properties: dict[str, str] :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -3255,6 +2933,37 @@ def __init__( extended_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword lab_storage_type: Type of storage used by the lab. It can be either Premium or + Standard. Default is Premium. Possible values include: "Standard", "Premium", "StandardSSD". + :paramtype lab_storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType + :keyword mandatory_artifacts_resource_ids_linux: The ordered list of artifact resource IDs that + should be applied on all Linux VM creations by default, prior to the artifacts specified by the + user. + :paramtype mandatory_artifacts_resource_ids_linux: list[str] + :keyword mandatory_artifacts_resource_ids_windows: The ordered list of artifact resource IDs + that should be applied on all Windows VM creations by default, prior to the artifacts specified + by the user. + :paramtype mandatory_artifacts_resource_ids_windows: list[str] + :keyword premium_data_disks: The setting to enable usage of premium data disks. + When its value is 'Enabled', creation of standard or premium data disks is allowed. + When its value is 'Disabled', only creation of standard data disks is allowed. Possible values + include: "Disabled", "Enabled". + :paramtype premium_data_disks: str or ~azure.mgmt.devtestlabs.models.PremiumDataDisk + :keyword environment_permission: The access rights to be granted to the user when provisioning + an environment. Possible values include: "Reader", "Contributor". + :paramtype environment_permission: str or ~azure.mgmt.devtestlabs.models.EnvironmentPermission + :keyword announcement: The properties of any lab announcement associated with this lab. + :paramtype announcement: ~azure.mgmt.devtestlabs.models.LabAnnouncementProperties + :keyword support: The properties of any lab support message associated with this lab. + :paramtype support: ~azure.mgmt.devtestlabs.models.LabSupportProperties + :keyword extended_properties: Extended properties of the lab used for experimental features. + :paramtype extended_properties: dict[str, str] + """ super(Lab, self).__init__(location=location, tags=tags, **kwargs) self.default_storage_account = None self.default_premium_storage_account = None @@ -3283,18 +2992,18 @@ class LabAnnouncementProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param title: The plain text title for the lab announcement. - :type title: str - :param markdown: The markdown text (if any) that this lab displays in the UI. If left + :ivar title: The plain text title for the lab announcement. + :vartype title: str + :ivar markdown: The markdown text (if any) that this lab displays in the UI. If left empty/null, nothing will be shown. - :type markdown: str - :param enabled: Is the lab announcement active/enabled at this time?. Possible values include: + :vartype markdown: str + :ivar enabled: Is the lab announcement active/enabled at this time?. Possible values include: "Enabled", "Disabled". - :type enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param expiration_date: The time at which the announcement expires (null for never). - :type expiration_date: ~datetime.datetime - :param expired: Has this announcement expired?. - :type expired: bool + :vartype enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :ivar expiration_date: The time at which the announcement expires (null for never). + :vartype expiration_date: ~datetime.datetime + :ivar expired: Has this announcement expired?. + :vartype expired: bool :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -3326,6 +3035,20 @@ def __init__( expired: Optional[bool] = None, **kwargs ): + """ + :keyword title: The plain text title for the lab announcement. + :paramtype title: str + :keyword markdown: The markdown text (if any) that this lab displays in the UI. If left + empty/null, nothing will be shown. + :paramtype markdown: str + :keyword enabled: Is the lab announcement active/enabled at this time?. Possible values + include: "Enabled", "Disabled". + :paramtype enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :keyword expiration_date: The time at which the announcement expires (null for never). + :paramtype expiration_date: ~datetime.datetime + :keyword expired: Has this announcement expired?. + :paramtype expired: bool + """ super(LabAnnouncementProperties, self).__init__(**kwargs) self.title = title self.markdown = markdown @@ -3336,49 +3059,6 @@ def __init__( self.unique_identifier = None -class LabAnnouncementPropertiesFragment(msrest.serialization.Model): - """Properties of a lab's announcement banner. - - :param title: The plain text title for the lab announcement. - :type title: str - :param markdown: The markdown text (if any) that this lab displays in the UI. If left - empty/null, nothing will be shown. - :type markdown: str - :param enabled: Is the lab announcement active/enabled at this time?. Possible values include: - "Enabled", "Disabled". - :type enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param expiration_date: The time at which the announcement expires (null for never). - :type expiration_date: ~datetime.datetime - :param expired: Has this announcement expired?. - :type expired: bool - """ - - _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'markdown': {'key': 'markdown', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'str'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'iso-8601'}, - 'expired': {'key': 'expired', 'type': 'bool'}, - } - - def __init__( - self, - *, - title: Optional[str] = None, - markdown: Optional[str] = None, - enabled: Optional[Union[str, "EnableStatus"]] = None, - expiration_date: Optional[datetime.datetime] = None, - expired: Optional[bool] = None, - **kwargs - ): - super(LabAnnouncementPropertiesFragment, self).__init__(**kwargs) - self.title = title - self.markdown = markdown - self.enabled = enabled - self.expiration_date = expiration_date - self.expired = expired - - class LabCost(Resource): """A cost item. @@ -3390,26 +3070,26 @@ class LabCost(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param target_cost: The target cost properties. - :type target_cost: ~azure.mgmt.devtestlabs.models.TargetCostProperties + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar target_cost: The target cost properties. + :vartype target_cost: ~azure.mgmt.devtestlabs.models.TargetCostProperties :ivar lab_cost_summary: The lab cost summary component of the cost data. :vartype lab_cost_summary: ~azure.mgmt.devtestlabs.models.LabCostSummaryProperties :ivar lab_cost_details: The lab cost details component of the cost data. :vartype lab_cost_details: list[~azure.mgmt.devtestlabs.models.LabCostDetailsProperties] :ivar resource_costs: The resource cost component of the cost data. :vartype resource_costs: list[~azure.mgmt.devtestlabs.models.LabResourceCostProperties] - :param currency_code: The currency code of the cost. - :type currency_code: str - :param start_date_time: The start time of the cost data. - :type start_date_time: ~datetime.datetime - :param end_date_time: The end time of the cost data. - :type end_date_time: ~datetime.datetime - :param created_date: The creation date of the cost. - :type created_date: ~datetime.datetime + :ivar currency_code: The currency code of the cost. + :vartype currency_code: str + :ivar start_date_time: The start time of the cost data. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The end time of the cost data. + :vartype end_date_time: ~datetime.datetime + :ivar created_date: The creation date of the cost. + :vartype created_date: ~datetime.datetime :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -3457,6 +3137,22 @@ def __init__( created_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword target_cost: The target cost properties. + :paramtype target_cost: ~azure.mgmt.devtestlabs.models.TargetCostProperties + :keyword currency_code: The currency code of the cost. + :paramtype currency_code: str + :keyword start_date_time: The start time of the cost data. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The end time of the cost data. + :paramtype end_date_time: ~datetime.datetime + :keyword created_date: The creation date of the cost. + :paramtype created_date: ~datetime.datetime + """ super(LabCost, self).__init__(location=location, tags=tags, **kwargs) self.target_cost = target_cost self.lab_cost_summary = None @@ -3473,13 +3169,13 @@ def __init__( class LabCostDetailsProperties(msrest.serialization.Model): """The properties of a lab cost item. - :param date: The date of the cost item. - :type date: ~datetime.datetime - :param cost: The cost component of the cost item. - :type cost: float - :param cost_type: The type of the cost. Possible values include: "Unavailable", "Reported", + :ivar date: The date of the cost item. + :vartype date: ~datetime.datetime + :ivar cost: The cost component of the cost item. + :vartype cost: float + :ivar cost_type: The type of the cost. Possible values include: "Unavailable", "Reported", "Projected". - :type cost_type: str or ~azure.mgmt.devtestlabs.models.CostType + :vartype cost_type: str or ~azure.mgmt.devtestlabs.models.CostType """ _attribute_map = { @@ -3496,6 +3192,15 @@ def __init__( cost_type: Optional[Union[str, "CostType"]] = None, **kwargs ): + """ + :keyword date: The date of the cost item. + :paramtype date: ~datetime.datetime + :keyword cost: The cost component of the cost item. + :paramtype cost: float + :keyword cost_type: The type of the cost. Possible values include: "Unavailable", "Reported", + "Projected". + :paramtype cost_type: str or ~azure.mgmt.devtestlabs.models.CostType + """ super(LabCostDetailsProperties, self).__init__(**kwargs) self.date = date self.cost = cost @@ -3505,8 +3210,8 @@ def __init__( class LabCostSummaryProperties(msrest.serialization.Model): """The properties of the cost summary. - :param estimated_lab_cost: The cost component of the cost item. - :type estimated_lab_cost: float + :ivar estimated_lab_cost: The cost component of the cost item. + :vartype estimated_lab_cost: float """ _attribute_map = { @@ -3519,6 +3224,10 @@ def __init__( estimated_lab_cost: Optional[float] = None, **kwargs ): + """ + :keyword estimated_lab_cost: The cost component of the cost item. + :paramtype estimated_lab_cost: float + """ super(LabCostSummaryProperties, self).__init__(**kwargs) self.estimated_lab_cost = estimated_lab_cost @@ -3526,79 +3235,34 @@ def __init__( class LabFragment(UpdateResource): """A lab. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param lab_storage_type: Type of storage used by the lab. It can be either Premium or Standard. - Default is Premium. Possible values include: "Standard", "Premium", "StandardSSD". - :type lab_storage_type: str or ~azure.mgmt.devtestlabs.models.StorageType - :param mandatory_artifacts_resource_ids_linux: The ordered list of artifact resource IDs that - should be applied on all Linux VM creations by default, prior to the artifacts specified by the - user. - :type mandatory_artifacts_resource_ids_linux: list[str] - :param mandatory_artifacts_resource_ids_windows: The ordered list of artifact resource IDs that - should be applied on all Windows VM creations by default, prior to the artifacts specified by - the user. - :type mandatory_artifacts_resource_ids_windows: list[str] - :param premium_data_disks: The setting to enable usage of premium data disks. - When its value is 'Enabled', creation of standard or premium data disks is allowed. - When its value is 'Disabled', only creation of standard data disks is allowed. Possible values - include: "Disabled", "Enabled". - :type premium_data_disks: str or ~azure.mgmt.devtestlabs.models.PremiumDataDisk - :param environment_permission: The access rights to be granted to the user when provisioning an - environment. Possible values include: "Reader", "Contributor". - :type environment_permission: str or ~azure.mgmt.devtestlabs.models.EnvironmentPermission - :param announcement: The properties of any lab announcement associated with this lab. - :type announcement: ~azure.mgmt.devtestlabs.models.LabAnnouncementPropertiesFragment - :param support: The properties of any lab support message associated with this lab. - :type support: ~azure.mgmt.devtestlabs.models.LabSupportPropertiesFragment - :param extended_properties: Extended properties of the lab used for experimental features. - :type extended_properties: dict[str, str] + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'lab_storage_type': {'key': 'properties.labStorageType', 'type': 'str'}, - 'mandatory_artifacts_resource_ids_linux': {'key': 'properties.mandatoryArtifactsResourceIdsLinux', 'type': '[str]'}, - 'mandatory_artifacts_resource_ids_windows': {'key': 'properties.mandatoryArtifactsResourceIdsWindows', 'type': '[str]'}, - 'premium_data_disks': {'key': 'properties.premiumDataDisks', 'type': 'str'}, - 'environment_permission': {'key': 'properties.environmentPermission', 'type': 'str'}, - 'announcement': {'key': 'properties.announcement', 'type': 'LabAnnouncementPropertiesFragment'}, - 'support': {'key': 'properties.support', 'type': 'LabSupportPropertiesFragment'}, - 'extended_properties': {'key': 'properties.extendedProperties', 'type': '{str}'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - lab_storage_type: Optional[Union[str, "StorageType"]] = None, - mandatory_artifacts_resource_ids_linux: Optional[List[str]] = None, - mandatory_artifacts_resource_ids_windows: Optional[List[str]] = None, - premium_data_disks: Optional[Union[str, "PremiumDataDisk"]] = None, - environment_permission: Optional[Union[str, "EnvironmentPermission"]] = None, - announcement: Optional["LabAnnouncementPropertiesFragment"] = None, - support: Optional["LabSupportPropertiesFragment"] = None, - extended_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(LabFragment, self).__init__(tags=tags, **kwargs) - self.lab_storage_type = lab_storage_type - self.mandatory_artifacts_resource_ids_linux = mandatory_artifacts_resource_ids_linux - self.mandatory_artifacts_resource_ids_windows = mandatory_artifacts_resource_ids_windows - self.premium_data_disks = premium_data_disks - self.environment_permission = environment_permission - self.announcement = announcement - self.support = support - self.extended_properties = extended_properties class LabList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Lab] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.Lab] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -3613,6 +3277,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.Lab] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(LabList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -3621,24 +3291,24 @@ def __init__( class LabResourceCostProperties(msrest.serialization.Model): """The properties of a resource cost item. - :param resourcename: The name of the resource. - :type resourcename: str - :param resource_u_id: The unique identifier of the resource. - :type resource_u_id: str - :param resource_cost: The cost component of the resource cost item. - :type resource_cost: float - :param resource_type: The logical resource type (ex. virtualmachine, storageaccount). - :type resource_type: str - :param resource_owner: The owner of the resource (ex. janedoe@microsoft.com). - :type resource_owner: str - :param resource_pricing_tier: The category of the resource (ex. Premium_LRS, Standard_DS1). - :type resource_pricing_tier: str - :param resource_status: The status of the resource (ex. Active). - :type resource_status: str - :param resource_id: The ID of the resource. - :type resource_id: str - :param external_resource_id: The ID of the external resource. - :type external_resource_id: str + :ivar resourcename: The name of the resource. + :vartype resourcename: str + :ivar resource_u_id: The unique identifier of the resource. + :vartype resource_u_id: str + :ivar resource_cost: The cost component of the resource cost item. + :vartype resource_cost: float + :ivar resource_type: The logical resource type (ex. virtualmachine, storageaccount). + :vartype resource_type: str + :ivar resource_owner: The owner of the resource (ex. janedoe@microsoft.com). + :vartype resource_owner: str + :ivar resource_pricing_tier: The category of the resource (ex. Premium_LRS, Standard_DS1). + :vartype resource_pricing_tier: str + :ivar resource_status: The status of the resource (ex. Active). + :vartype resource_status: str + :ivar resource_id: The ID of the resource. + :vartype resource_id: str + :ivar external_resource_id: The ID of the external resource. + :vartype external_resource_id: str """ _attribute_map = { @@ -3667,6 +3337,26 @@ def __init__( external_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword resourcename: The name of the resource. + :paramtype resourcename: str + :keyword resource_u_id: The unique identifier of the resource. + :paramtype resource_u_id: str + :keyword resource_cost: The cost component of the resource cost item. + :paramtype resource_cost: float + :keyword resource_type: The logical resource type (ex. virtualmachine, storageaccount). + :paramtype resource_type: str + :keyword resource_owner: The owner of the resource (ex. janedoe@microsoft.com). + :paramtype resource_owner: str + :keyword resource_pricing_tier: The category of the resource (ex. Premium_LRS, Standard_DS1). + :paramtype resource_pricing_tier: str + :keyword resource_status: The status of the resource (ex. Active). + :paramtype resource_status: str + :keyword resource_id: The ID of the resource. + :paramtype resource_id: str + :keyword external_resource_id: The ID of the external resource. + :paramtype external_resource_id: str + """ super(LabResourceCostProperties, self).__init__(**kwargs) self.resourcename = resourcename self.resource_u_id = resource_u_id @@ -3682,12 +3372,12 @@ def __init__( class LabSupportProperties(msrest.serialization.Model): """Properties of a lab's support banner. - :param enabled: Is the lab support banner active/enabled at this time?. Possible values - include: "Enabled", "Disabled". - :type enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param markdown: The markdown text (if any) that this lab displays in the UI. If left + :ivar enabled: Is the lab support banner active/enabled at this time?. Possible values include: + "Enabled", "Disabled". + :vartype enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :ivar markdown: The markdown text (if any) that this lab displays in the UI. If left empty/null, nothing will be shown. - :type markdown: str + :vartype markdown: str """ _attribute_map = { @@ -3702,44 +3392,24 @@ def __init__( markdown: Optional[str] = None, **kwargs ): + """ + :keyword enabled: Is the lab support banner active/enabled at this time?. Possible values + include: "Enabled", "Disabled". + :paramtype enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :keyword markdown: The markdown text (if any) that this lab displays in the UI. If left + empty/null, nothing will be shown. + :paramtype markdown: str + """ super(LabSupportProperties, self).__init__(**kwargs) self.enabled = enabled self.markdown = markdown -class LabSupportPropertiesFragment(msrest.serialization.Model): - """Properties of a lab's support banner. - - :param enabled: Is the lab support banner active/enabled at this time?. Possible values - include: "Enabled", "Disabled". - :type enabled: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param markdown: The markdown text (if any) that this lab displays in the UI. If left - empty/null, nothing will be shown. - :type markdown: str - """ - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'str'}, - 'markdown': {'key': 'markdown', 'type': 'str'}, - } - - def __init__( - self, - *, - enabled: Optional[Union[str, "EnableStatus"]] = None, - markdown: Optional[str] = None, - **kwargs - ): - super(LabSupportPropertiesFragment, self).__init__(**kwargs) - self.enabled = enabled - self.markdown = markdown - - class LabVhd(msrest.serialization.Model): """Properties of a VHD in the lab. - :param id: The URI to the VHD. - :type id: str + :ivar id: The URI to the VHD. + :vartype id: str """ _attribute_map = { @@ -3752,6 +3422,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The URI to the VHD. + :paramtype id: str + """ super(LabVhd, self).__init__(**kwargs) self.id = id @@ -3759,10 +3433,10 @@ def __init__( class LabVhdList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.LabVhd] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.LabVhd] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -3777,6 +3451,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.LabVhd] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(LabVhdList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -3793,85 +3473,85 @@ class LabVirtualMachine(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param notes: The notes of the virtual machine. - :type notes: str - :param owner_object_id: The object identifier of the owner of the virtual machine. - :type owner_object_id: str - :param owner_user_principal_name: The user principal name of the virtual machine owner. - :type owner_user_principal_name: str - :param created_by_user_id: The object identifier of the creator of the virtual machine. - :type created_by_user_id: str - :param created_by_user: The email address of creator of the virtual machine. - :type created_by_user: str - :param created_date: The creation date of the virtual machine. - :type created_date: ~datetime.datetime - :param compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. - :type compute_id: str - :param custom_image_id: The custom image identifier of the virtual machine. - :type custom_image_id: str - :param os_type: The OS type of the virtual machine. - :type os_type: str - :param size: The size of the virtual machine. - :type size: str - :param user_name: The user name of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine administrator. - :type password: str - :param ssh_key: The SSH key of the virtual machine administrator. - :type ssh_key: str - :param is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar notes: The notes of the virtual machine. + :vartype notes: str + :ivar owner_object_id: The object identifier of the owner of the virtual machine. + :vartype owner_object_id: str + :ivar owner_user_principal_name: The user principal name of the virtual machine owner. + :vartype owner_user_principal_name: str + :ivar created_by_user_id: The object identifier of the creator of the virtual machine. + :vartype created_by_user_id: str + :ivar created_by_user: The email address of creator of the virtual machine. + :vartype created_by_user: str + :ivar created_date: The creation date of the virtual machine. + :vartype created_date: ~datetime.datetime + :ivar compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. + :vartype compute_id: str + :ivar custom_image_id: The custom image identifier of the virtual machine. + :vartype custom_image_id: str + :ivar os_type: The OS type of the virtual machine. + :vartype os_type: str + :ivar size: The size of the virtual machine. + :vartype size: str + :ivar user_name: The user name of the virtual machine. + :vartype user_name: str + :ivar password: The password of the virtual machine administrator. + :vartype password: str + :ivar ssh_key: The SSH key of the virtual machine administrator. + :vartype ssh_key: str + :ivar is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key for authentication. - :type is_authentication_with_ssh_key: bool - :param fqdn: The fully-qualified domain name of the virtual machine. - :type fqdn: str - :param lab_subnet_name: The lab subnet name of the virtual machine. - :type lab_subnet_name: str - :param lab_virtual_network_id: The lab virtual network identifier of the virtual machine. - :type lab_virtual_network_id: str - :param disallow_public_ip_address: Indicates whether the virtual machine is to be created + :vartype is_authentication_with_ssh_key: bool + :ivar fqdn: The fully-qualified domain name of the virtual machine. + :vartype fqdn: str + :ivar lab_subnet_name: The lab subnet name of the virtual machine. + :vartype lab_subnet_name: str + :ivar lab_virtual_network_id: The lab virtual network identifier of the virtual machine. + :vartype lab_virtual_network_id: str + :ivar disallow_public_ip_address: Indicates whether the virtual machine is to be created without a public IP address. - :type disallow_public_ip_address: bool - :param artifacts: The artifacts to be installed on the virtual machine. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] - :param artifact_deployment_status: The artifact deployment status for the virtual machine. - :type artifact_deployment_status: + :vartype disallow_public_ip_address: bool + :ivar artifacts: The artifacts to be installed on the virtual machine. + :vartype artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] + :ivar artifact_deployment_status: The artifact deployment status for the virtual machine. + :vartype artifact_deployment_status: ~azure.mgmt.devtestlabs.models.ArtifactDeploymentStatusProperties - :param gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual + :ivar gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual machine. - :type gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference - :param plan_id: The id of the plan associated with the virtual machine image. - :type plan_id: str + :vartype gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference + :ivar plan_id: The id of the plan associated with the virtual machine image. + :vartype plan_id: str :ivar compute_vm: The compute virtual machine properties. :vartype compute_vm: ~azure.mgmt.devtestlabs.models.ComputeVmProperties - :param network_interface: The network interface properties. - :type network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfaceProperties + :ivar network_interface: The network interface properties. + :vartype network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfaceProperties :ivar applicable_schedule: The applicable schedule for the virtual machine. :vartype applicable_schedule: ~azure.mgmt.devtestlabs.models.ApplicableSchedule - :param expiration_date: The expiration date for VM. - :type expiration_date: ~datetime.datetime - :param allow_claim: Indicates whether another user can take ownership of the virtual machine. - :type allow_claim: bool - :param storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). - :type storage_type: str - :param virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output + :ivar expiration_date: The expiration date for VM. + :vartype expiration_date: ~datetime.datetime + :ivar allow_claim: Indicates whether another user can take ownership of the virtual machine. + :vartype allow_claim: bool + :ivar storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). + :vartype storage_type: str + :ivar virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output property only. Possible values include: "FromCustomImage", "FromGalleryImage", "FromSharedGalleryImage". - :type virtual_machine_creation_source: str or + :vartype virtual_machine_creation_source: str or ~azure.mgmt.devtestlabs.models.VirtualMachineCreationSource - :param environment_id: The resource ID of the environment that contains this virtual machine, - if any. - :type environment_id: str - :param data_disk_parameters: New or existing data disks to attach to the virtual machine after + :ivar environment_id: The resource ID of the environment that contains this virtual machine, if + any. + :vartype environment_id: str + :ivar data_disk_parameters: New or existing data disks to attach to the virtual machine after creation. - :type data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskProperties] - :param schedule_parameters: Virtual Machine schedules to be created. - :type schedule_parameters: list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameter] - :param last_known_power_state: Last known compute power state captured in DTL. - :type last_known_power_state: str + :vartype data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskProperties] + :ivar schedule_parameters: Virtual Machine schedules to be created. + :vartype schedule_parameters: list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameter] + :ivar last_known_power_state: Last known compute power state captured in DTL. + :vartype last_known_power_state: str :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -3882,8 +3562,16 @@ class LabVirtualMachine(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'created_by_user_id': {'readonly': True}, + 'created_by_user': {'readonly': True}, + 'compute_id': {'readonly': True}, + 'os_type': {'readonly': True}, + 'fqdn': {'readonly': True}, + 'artifact_deployment_status': {'readonly': True}, 'compute_vm': {'readonly': True}, 'applicable_schedule': {'readonly': True}, + 'virtual_machine_creation_source': {'readonly': True}, + 'last_known_power_state': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'unique_identifier': {'readonly': True}, } @@ -3937,59 +3625,108 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, notes: Optional[str] = None, - owner_object_id: Optional[str] = None, + owner_object_id: Optional[str] = "dynamicValue", owner_user_principal_name: Optional[str] = None, - created_by_user_id: Optional[str] = None, - created_by_user: Optional[str] = None, created_date: Optional[datetime.datetime] = None, - compute_id: Optional[str] = None, custom_image_id: Optional[str] = None, - os_type: Optional[str] = None, size: Optional[str] = None, user_name: Optional[str] = None, password: Optional[str] = None, ssh_key: Optional[str] = None, is_authentication_with_ssh_key: Optional[bool] = None, - fqdn: Optional[str] = None, lab_subnet_name: Optional[str] = None, lab_virtual_network_id: Optional[str] = None, - disallow_public_ip_address: Optional[bool] = None, + disallow_public_ip_address: Optional[bool] = False, artifacts: Optional[List["ArtifactInstallProperties"]] = None, - artifact_deployment_status: Optional["ArtifactDeploymentStatusProperties"] = None, gallery_image_reference: Optional["GalleryImageReference"] = None, plan_id: Optional[str] = None, network_interface: Optional["NetworkInterfaceProperties"] = None, expiration_date: Optional[datetime.datetime] = None, - allow_claim: Optional[bool] = None, - storage_type: Optional[str] = None, - virtual_machine_creation_source: Optional[Union[str, "VirtualMachineCreationSource"]] = None, + allow_claim: Optional[bool] = False, + storage_type: Optional[str] = "labStorageType", environment_id: Optional[str] = None, data_disk_parameters: Optional[List["DataDiskProperties"]] = None, schedule_parameters: Optional[List["ScheduleCreationParameter"]] = None, - last_known_power_state: Optional[str] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword notes: The notes of the virtual machine. + :paramtype notes: str + :keyword owner_object_id: The object identifier of the owner of the virtual machine. + :paramtype owner_object_id: str + :keyword owner_user_principal_name: The user principal name of the virtual machine owner. + :paramtype owner_user_principal_name: str + :keyword created_date: The creation date of the virtual machine. + :paramtype created_date: ~datetime.datetime + :keyword custom_image_id: The custom image identifier of the virtual machine. + :paramtype custom_image_id: str + :keyword size: The size of the virtual machine. + :paramtype size: str + :keyword user_name: The user name of the virtual machine. + :paramtype user_name: str + :keyword password: The password of the virtual machine administrator. + :paramtype password: str + :keyword ssh_key: The SSH key of the virtual machine administrator. + :paramtype ssh_key: str + :keyword is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key + for authentication. + :paramtype is_authentication_with_ssh_key: bool + :keyword lab_subnet_name: The lab subnet name of the virtual machine. + :paramtype lab_subnet_name: str + :keyword lab_virtual_network_id: The lab virtual network identifier of the virtual machine. + :paramtype lab_virtual_network_id: str + :keyword disallow_public_ip_address: Indicates whether the virtual machine is to be created + without a public IP address. + :paramtype disallow_public_ip_address: bool + :keyword artifacts: The artifacts to be installed on the virtual machine. + :paramtype artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] + :keyword gallery_image_reference: The Microsoft Azure Marketplace image reference of the + virtual machine. + :paramtype gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference + :keyword plan_id: The id of the plan associated with the virtual machine image. + :paramtype plan_id: str + :keyword network_interface: The network interface properties. + :paramtype network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfaceProperties + :keyword expiration_date: The expiration date for VM. + :paramtype expiration_date: ~datetime.datetime + :keyword allow_claim: Indicates whether another user can take ownership of the virtual machine. + :paramtype allow_claim: bool + :keyword storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). + :paramtype storage_type: str + :keyword environment_id: The resource ID of the environment that contains this virtual machine, + if any. + :paramtype environment_id: str + :keyword data_disk_parameters: New or existing data disks to attach to the virtual machine + after creation. + :paramtype data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskProperties] + :keyword schedule_parameters: Virtual Machine schedules to be created. + :paramtype schedule_parameters: list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameter] + """ super(LabVirtualMachine, self).__init__(location=location, tags=tags, **kwargs) self.notes = notes self.owner_object_id = owner_object_id self.owner_user_principal_name = owner_user_principal_name - self.created_by_user_id = created_by_user_id - self.created_by_user = created_by_user + self.created_by_user_id = None + self.created_by_user = None self.created_date = created_date - self.compute_id = compute_id + self.compute_id = None self.custom_image_id = custom_image_id - self.os_type = os_type + self.os_type = None self.size = size self.user_name = user_name self.password = password self.ssh_key = ssh_key self.is_authentication_with_ssh_key = is_authentication_with_ssh_key - self.fqdn = fqdn + self.fqdn = None self.lab_subnet_name = lab_subnet_name self.lab_virtual_network_id = lab_virtual_network_id self.disallow_public_ip_address = disallow_public_ip_address self.artifacts = artifacts - self.artifact_deployment_status = artifact_deployment_status + self.artifact_deployment_status = None self.gallery_image_reference = gallery_image_reference self.plan_id = plan_id self.compute_vm = None @@ -3998,11 +3735,11 @@ def __init__( self.expiration_date = expiration_date self.allow_claim = allow_claim self.storage_type = storage_type - self.virtual_machine_creation_source = virtual_machine_creation_source + self.virtual_machine_creation_source = None self.environment_id = environment_id self.data_disk_parameters = data_disk_parameters self.schedule_parameters = schedule_parameters - self.last_known_power_state = last_known_power_state + self.last_known_power_state = None self.provisioning_state = None self.unique_identifier = None @@ -4010,645 +3747,283 @@ def __init__( class LabVirtualMachineCreationParameter(msrest.serialization.Model): """Properties for creating a virtual machine. - :param name: The name of the virtual machine or environment. - :type name: str - :param location: The location of the new virtual machine or environment. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param bulk_creation_parameters: The number of virtual machine instances to create. - :type bulk_creation_parameters: ~azure.mgmt.devtestlabs.models.BulkCreationParameters - :param notes: The notes of the virtual machine. - :type notes: str - :param owner_object_id: The object identifier of the owner of the virtual machine. - :type owner_object_id: str - :param owner_user_principal_name: The user principal name of the virtual machine owner. - :type owner_user_principal_name: str - :param created_by_user_id: The object identifier of the creator of the virtual machine. - :type created_by_user_id: str - :param created_by_user: The email address of creator of the virtual machine. - :type created_by_user: str - :param created_date: The creation date of the virtual machine. - :type created_date: ~datetime.datetime - :param compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. - :type compute_id: str - :param custom_image_id: The custom image identifier of the virtual machine. - :type custom_image_id: str - :param os_type: The OS type of the virtual machine. - :type os_type: str - :param size: The size of the virtual machine. - :type size: str - :param user_name: The user name of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine administrator. - :type password: str - :param ssh_key: The SSH key of the virtual machine administrator. - :type ssh_key: str - :param is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key - for authentication. - :type is_authentication_with_ssh_key: bool - :param fqdn: The fully-qualified domain name of the virtual machine. - :type fqdn: str - :param lab_subnet_name: The lab subnet name of the virtual machine. - :type lab_subnet_name: str - :param lab_virtual_network_id: The lab virtual network identifier of the virtual machine. - :type lab_virtual_network_id: str - :param disallow_public_ip_address: Indicates whether the virtual machine is to be created - without a public IP address. - :type disallow_public_ip_address: bool - :param artifacts: The artifacts to be installed on the virtual machine. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] - :param artifact_deployment_status: The artifact deployment status for the virtual machine. - :type artifact_deployment_status: - ~azure.mgmt.devtestlabs.models.ArtifactDeploymentStatusProperties - :param gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual - machine. - :type gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference - :param plan_id: The id of the plan associated with the virtual machine image. - :type plan_id: str - :param network_interface: The network interface properties. - :type network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfaceProperties - :param expiration_date: The expiration date for VM. - :type expiration_date: ~datetime.datetime - :param allow_claim: Indicates whether another user can take ownership of the virtual machine. - :type allow_claim: bool - :param storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). - :type storage_type: str - :param virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output - property only. Possible values include: "FromCustomImage", "FromGalleryImage", - "FromSharedGalleryImage". - :type virtual_machine_creation_source: str or - ~azure.mgmt.devtestlabs.models.VirtualMachineCreationSource - :param environment_id: The resource ID of the environment that contains this virtual machine, - if any. - :type environment_id: str - :param data_disk_parameters: New or existing data disks to attach to the virtual machine after - creation. - :type data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskProperties] - :param schedule_parameters: Virtual Machine schedules to be created. - :type schedule_parameters: list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameter] - :param last_known_power_state: Last known compute power state captured in DTL. - :type last_known_power_state: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'bulk_creation_parameters': {'key': 'properties.bulkCreationParameters', 'type': 'BulkCreationParameters'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owner_object_id': {'key': 'properties.ownerObjectId', 'type': 'str'}, - 'owner_user_principal_name': {'key': 'properties.ownerUserPrincipalName', 'type': 'str'}, - 'created_by_user_id': {'key': 'properties.createdByUserId', 'type': 'str'}, - 'created_by_user': {'key': 'properties.createdByUser', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'compute_id': {'key': 'properties.computeId', 'type': 'str'}, - 'custom_image_id': {'key': 'properties.customImageId', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'size': {'key': 'properties.size', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'ssh_key': {'key': 'properties.sshKey', 'type': 'str'}, - 'is_authentication_with_ssh_key': {'key': 'properties.isAuthenticationWithSshKey', 'type': 'bool'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'lab_subnet_name': {'key': 'properties.labSubnetName', 'type': 'str'}, - 'lab_virtual_network_id': {'key': 'properties.labVirtualNetworkId', 'type': 'str'}, - 'disallow_public_ip_address': {'key': 'properties.disallowPublicIpAddress', 'type': 'bool'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[ArtifactInstallProperties]'}, - 'artifact_deployment_status': {'key': 'properties.artifactDeploymentStatus', 'type': 'ArtifactDeploymentStatusProperties'}, - 'gallery_image_reference': {'key': 'properties.galleryImageReference', 'type': 'GalleryImageReference'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterfaceProperties'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'allow_claim': {'key': 'properties.allowClaim', 'type': 'bool'}, - 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, - 'virtual_machine_creation_source': {'key': 'properties.virtualMachineCreationSource', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - 'data_disk_parameters': {'key': 'properties.dataDiskParameters', 'type': '[DataDiskProperties]'}, - 'schedule_parameters': {'key': 'properties.scheduleParameters', 'type': '[ScheduleCreationParameter]'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - bulk_creation_parameters: Optional["BulkCreationParameters"] = None, - notes: Optional[str] = None, - owner_object_id: Optional[str] = None, - owner_user_principal_name: Optional[str] = None, - created_by_user_id: Optional[str] = None, - created_by_user: Optional[str] = None, - created_date: Optional[datetime.datetime] = None, - compute_id: Optional[str] = None, - custom_image_id: Optional[str] = None, - os_type: Optional[str] = None, - size: Optional[str] = None, - user_name: Optional[str] = None, - password: Optional[str] = None, - ssh_key: Optional[str] = None, - is_authentication_with_ssh_key: Optional[bool] = None, - fqdn: Optional[str] = None, - lab_subnet_name: Optional[str] = None, - lab_virtual_network_id: Optional[str] = None, - disallow_public_ip_address: Optional[bool] = None, - artifacts: Optional[List["ArtifactInstallProperties"]] = None, - artifact_deployment_status: Optional["ArtifactDeploymentStatusProperties"] = None, - gallery_image_reference: Optional["GalleryImageReference"] = None, - plan_id: Optional[str] = None, - network_interface: Optional["NetworkInterfaceProperties"] = None, - expiration_date: Optional[datetime.datetime] = None, - allow_claim: Optional[bool] = None, - storage_type: Optional[str] = None, - virtual_machine_creation_source: Optional[Union[str, "VirtualMachineCreationSource"]] = None, - environment_id: Optional[str] = None, - data_disk_parameters: Optional[List["DataDiskProperties"]] = None, - schedule_parameters: Optional[List["ScheduleCreationParameter"]] = None, - last_known_power_state: Optional[str] = None, - **kwargs - ): - super(LabVirtualMachineCreationParameter, self).__init__(**kwargs) - self.name = name - self.location = location - self.tags = tags - self.bulk_creation_parameters = bulk_creation_parameters - self.notes = notes - self.owner_object_id = owner_object_id - self.owner_user_principal_name = owner_user_principal_name - self.created_by_user_id = created_by_user_id - self.created_by_user = created_by_user - self.created_date = created_date - self.compute_id = compute_id - self.custom_image_id = custom_image_id - self.os_type = os_type - self.size = size - self.user_name = user_name - self.password = password - self.ssh_key = ssh_key - self.is_authentication_with_ssh_key = is_authentication_with_ssh_key - self.fqdn = fqdn - self.lab_subnet_name = lab_subnet_name - self.lab_virtual_network_id = lab_virtual_network_id - self.disallow_public_ip_address = disallow_public_ip_address - self.artifacts = artifacts - self.artifact_deployment_status = artifact_deployment_status - self.gallery_image_reference = gallery_image_reference - self.plan_id = plan_id - self.network_interface = network_interface - self.expiration_date = expiration_date - self.allow_claim = allow_claim - self.storage_type = storage_type - self.virtual_machine_creation_source = virtual_machine_creation_source - self.environment_id = environment_id - self.data_disk_parameters = data_disk_parameters - self.schedule_parameters = schedule_parameters - self.last_known_power_state = last_known_power_state - - -class LabVirtualMachineCreationParameterFragment(msrest.serialization.Model): - """Properties for creating a virtual machine. - - :param name: The name of the virtual machine or environment. - :type name: str - :param location: The location of the new virtual machine or environment. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param bulk_creation_parameters: The number of virtual machine instances to create. - :type bulk_creation_parameters: ~azure.mgmt.devtestlabs.models.BulkCreationParametersFragment - :param notes: The notes of the virtual machine. - :type notes: str - :param owner_object_id: The object identifier of the owner of the virtual machine. - :type owner_object_id: str - :param owner_user_principal_name: The user principal name of the virtual machine owner. - :type owner_user_principal_name: str - :param created_by_user_id: The object identifier of the creator of the virtual machine. - :type created_by_user_id: str - :param created_by_user: The email address of creator of the virtual machine. - :type created_by_user: str - :param created_date: The creation date of the virtual machine. - :type created_date: ~datetime.datetime - :param compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. - :type compute_id: str - :param custom_image_id: The custom image identifier of the virtual machine. - :type custom_image_id: str - :param os_type: The OS type of the virtual machine. - :type os_type: str - :param size: The size of the virtual machine. - :type size: str - :param user_name: The user name of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine administrator. - :type password: str - :param ssh_key: The SSH key of the virtual machine administrator. - :type ssh_key: str - :param is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key - for authentication. - :type is_authentication_with_ssh_key: bool - :param fqdn: The fully-qualified domain name of the virtual machine. - :type fqdn: str - :param lab_subnet_name: The lab subnet name of the virtual machine. - :type lab_subnet_name: str - :param lab_virtual_network_id: The lab virtual network identifier of the virtual machine. - :type lab_virtual_network_id: str - :param disallow_public_ip_address: Indicates whether the virtual machine is to be created - without a public IP address. - :type disallow_public_ip_address: bool - :param artifacts: The artifacts to be installed on the virtual machine. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallPropertiesFragment] - :param artifact_deployment_status: The artifact deployment status for the virtual machine. - :type artifact_deployment_status: - ~azure.mgmt.devtestlabs.models.ArtifactDeploymentStatusPropertiesFragment - :param gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual - machine. - :type gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReferenceFragment - :param plan_id: The id of the plan associated with the virtual machine image. - :type plan_id: str - :param network_interface: The network interface properties. - :type network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfacePropertiesFragment - :param expiration_date: The expiration date for VM. - :type expiration_date: ~datetime.datetime - :param allow_claim: Indicates whether another user can take ownership of the virtual machine. - :type allow_claim: bool - :param storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). - :type storage_type: str - :param virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output - property only. Possible values include: "FromCustomImage", "FromGalleryImage", - "FromSharedGalleryImage". - :type virtual_machine_creation_source: str or - ~azure.mgmt.devtestlabs.models.VirtualMachineCreationSource - :param environment_id: The resource ID of the environment that contains this virtual machine, - if any. - :type environment_id: str - :param data_disk_parameters: New or existing data disks to attach to the virtual machine after - creation. - :type data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskPropertiesFragment] - :param schedule_parameters: Virtual Machine schedules to be created. - :type schedule_parameters: - list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameterFragment] - :param last_known_power_state: Last known compute power state captured in DTL. - :type last_known_power_state: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'bulk_creation_parameters': {'key': 'properties.bulkCreationParameters', 'type': 'BulkCreationParametersFragment'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owner_object_id': {'key': 'properties.ownerObjectId', 'type': 'str'}, - 'owner_user_principal_name': {'key': 'properties.ownerUserPrincipalName', 'type': 'str'}, - 'created_by_user_id': {'key': 'properties.createdByUserId', 'type': 'str'}, - 'created_by_user': {'key': 'properties.createdByUser', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'compute_id': {'key': 'properties.computeId', 'type': 'str'}, - 'custom_image_id': {'key': 'properties.customImageId', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'size': {'key': 'properties.size', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'ssh_key': {'key': 'properties.sshKey', 'type': 'str'}, - 'is_authentication_with_ssh_key': {'key': 'properties.isAuthenticationWithSshKey', 'type': 'bool'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'lab_subnet_name': {'key': 'properties.labSubnetName', 'type': 'str'}, - 'lab_virtual_network_id': {'key': 'properties.labVirtualNetworkId', 'type': 'str'}, - 'disallow_public_ip_address': {'key': 'properties.disallowPublicIpAddress', 'type': 'bool'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[ArtifactInstallPropertiesFragment]'}, - 'artifact_deployment_status': {'key': 'properties.artifactDeploymentStatus', 'type': 'ArtifactDeploymentStatusPropertiesFragment'}, - 'gallery_image_reference': {'key': 'properties.galleryImageReference', 'type': 'GalleryImageReferenceFragment'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterfacePropertiesFragment'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'allow_claim': {'key': 'properties.allowClaim', 'type': 'bool'}, - 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, - 'virtual_machine_creation_source': {'key': 'properties.virtualMachineCreationSource', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - 'data_disk_parameters': {'key': 'properties.dataDiskParameters', 'type': '[DataDiskPropertiesFragment]'}, - 'schedule_parameters': {'key': 'properties.scheduleParameters', 'type': '[ScheduleCreationParameterFragment]'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - bulk_creation_parameters: Optional["BulkCreationParametersFragment"] = None, - notes: Optional[str] = None, - owner_object_id: Optional[str] = None, - owner_user_principal_name: Optional[str] = None, - created_by_user_id: Optional[str] = None, - created_by_user: Optional[str] = None, - created_date: Optional[datetime.datetime] = None, - compute_id: Optional[str] = None, - custom_image_id: Optional[str] = None, - os_type: Optional[str] = None, - size: Optional[str] = None, - user_name: Optional[str] = None, - password: Optional[str] = None, - ssh_key: Optional[str] = None, - is_authentication_with_ssh_key: Optional[bool] = None, - fqdn: Optional[str] = None, - lab_subnet_name: Optional[str] = None, - lab_virtual_network_id: Optional[str] = None, - disallow_public_ip_address: Optional[bool] = None, - artifacts: Optional[List["ArtifactInstallPropertiesFragment"]] = None, - artifact_deployment_status: Optional["ArtifactDeploymentStatusPropertiesFragment"] = None, - gallery_image_reference: Optional["GalleryImageReferenceFragment"] = None, - plan_id: Optional[str] = None, - network_interface: Optional["NetworkInterfacePropertiesFragment"] = None, - expiration_date: Optional[datetime.datetime] = None, - allow_claim: Optional[bool] = None, - storage_type: Optional[str] = None, - virtual_machine_creation_source: Optional[Union[str, "VirtualMachineCreationSource"]] = None, - environment_id: Optional[str] = None, - data_disk_parameters: Optional[List["DataDiskPropertiesFragment"]] = None, - schedule_parameters: Optional[List["ScheduleCreationParameterFragment"]] = None, - last_known_power_state: Optional[str] = None, - **kwargs - ): - super(LabVirtualMachineCreationParameterFragment, self).__init__(**kwargs) - self.name = name - self.location = location - self.tags = tags - self.bulk_creation_parameters = bulk_creation_parameters - self.notes = notes - self.owner_object_id = owner_object_id - self.owner_user_principal_name = owner_user_principal_name - self.created_by_user_id = created_by_user_id - self.created_by_user = created_by_user - self.created_date = created_date - self.compute_id = compute_id - self.custom_image_id = custom_image_id - self.os_type = os_type - self.size = size - self.user_name = user_name - self.password = password - self.ssh_key = ssh_key - self.is_authentication_with_ssh_key = is_authentication_with_ssh_key - self.fqdn = fqdn - self.lab_subnet_name = lab_subnet_name - self.lab_virtual_network_id = lab_virtual_network_id - self.disallow_public_ip_address = disallow_public_ip_address - self.artifacts = artifacts - self.artifact_deployment_status = artifact_deployment_status - self.gallery_image_reference = gallery_image_reference - self.plan_id = plan_id - self.network_interface = network_interface - self.expiration_date = expiration_date - self.allow_claim = allow_claim - self.storage_type = storage_type - self.virtual_machine_creation_source = virtual_machine_creation_source - self.environment_id = environment_id - self.data_disk_parameters = data_disk_parameters - self.schedule_parameters = schedule_parameters - self.last_known_power_state = last_known_power_state - - -class LabVirtualMachineFragment(UpdateResource): - """A virtual machine. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param notes: The notes of the virtual machine. - :type notes: str - :param owner_object_id: The object identifier of the owner of the virtual machine. - :type owner_object_id: str - :param owner_user_principal_name: The user principal name of the virtual machine owner. - :type owner_user_principal_name: str - :param created_by_user_id: The object identifier of the creator of the virtual machine. - :type created_by_user_id: str - :param created_by_user: The email address of creator of the virtual machine. - :type created_by_user: str - :param created_date: The creation date of the virtual machine. - :type created_date: ~datetime.datetime - :param compute_id: The resource identifier (Microsoft.Compute) of the virtual machine. - :type compute_id: str - :param custom_image_id: The custom image identifier of the virtual machine. - :type custom_image_id: str - :param os_type: The OS type of the virtual machine. - :type os_type: str - :param size: The size of the virtual machine. - :type size: str - :param user_name: The user name of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine administrator. - :type password: str - :param ssh_key: The SSH key of the virtual machine administrator. - :type ssh_key: str - :param is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key + :ivar name: The name of the virtual machine or environment. + :vartype name: str + :ivar location: The location of the new virtual machine or environment. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar bulk_creation_parameters: The number of virtual machine instances to create. + :vartype bulk_creation_parameters: ~azure.mgmt.devtestlabs.models.BulkCreationParameters + :ivar notes: The notes of the virtual machine. + :vartype notes: str + :ivar owner_object_id: The object identifier of the owner of the virtual machine. + :vartype owner_object_id: str + :ivar owner_user_principal_name: The user principal name of the virtual machine owner. + :vartype owner_user_principal_name: str + :ivar created_date: The creation date of the virtual machine. + :vartype created_date: ~datetime.datetime + :ivar custom_image_id: The custom image identifier of the virtual machine. + :vartype custom_image_id: str + :ivar size: The size of the virtual machine. + :vartype size: str + :ivar user_name: The user name of the virtual machine. + :vartype user_name: str + :ivar password: The password of the virtual machine administrator. + :vartype password: str + :ivar ssh_key: The SSH key of the virtual machine administrator. + :vartype ssh_key: str + :ivar is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key for authentication. - :type is_authentication_with_ssh_key: bool - :param fqdn: The fully-qualified domain name of the virtual machine. - :type fqdn: str - :param lab_subnet_name: The lab subnet name of the virtual machine. - :type lab_subnet_name: str - :param lab_virtual_network_id: The lab virtual network identifier of the virtual machine. - :type lab_virtual_network_id: str - :param disallow_public_ip_address: Indicates whether the virtual machine is to be created + :vartype is_authentication_with_ssh_key: bool + :ivar lab_subnet_name: The lab subnet name of the virtual machine. + :vartype lab_subnet_name: str + :ivar lab_virtual_network_id: The lab virtual network identifier of the virtual machine. + :vartype lab_virtual_network_id: str + :ivar disallow_public_ip_address: Indicates whether the virtual machine is to be created without a public IP address. - :type disallow_public_ip_address: bool - :param artifacts: The artifacts to be installed on the virtual machine. - :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallPropertiesFragment] - :param artifact_deployment_status: The artifact deployment status for the virtual machine. - :type artifact_deployment_status: - ~azure.mgmt.devtestlabs.models.ArtifactDeploymentStatusPropertiesFragment - :param gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual + :vartype disallow_public_ip_address: bool + :ivar artifacts: The artifacts to be installed on the virtual machine. + :vartype artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] + :ivar gallery_image_reference: The Microsoft Azure Marketplace image reference of the virtual machine. - :type gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReferenceFragment - :param plan_id: The id of the plan associated with the virtual machine image. - :type plan_id: str - :param network_interface: The network interface properties. - :type network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfacePropertiesFragment - :param expiration_date: The expiration date for VM. - :type expiration_date: ~datetime.datetime - :param allow_claim: Indicates whether another user can take ownership of the virtual machine. - :type allow_claim: bool - :param storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). - :type storage_type: str - :param virtual_machine_creation_source: Tells source of creation of lab virtual machine. Output - property only. Possible values include: "FromCustomImage", "FromGalleryImage", - "FromSharedGalleryImage". - :type virtual_machine_creation_source: str or - ~azure.mgmt.devtestlabs.models.VirtualMachineCreationSource - :param environment_id: The resource ID of the environment that contains this virtual machine, - if any. - :type environment_id: str - :param data_disk_parameters: New or existing data disks to attach to the virtual machine after + :vartype gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference + :ivar plan_id: The id of the plan associated with the virtual machine image. + :vartype plan_id: str + :ivar network_interface: The network interface properties. + :vartype network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfaceProperties + :ivar expiration_date: The expiration date for VM. + :vartype expiration_date: ~datetime.datetime + :ivar allow_claim: Indicates whether another user can take ownership of the virtual machine. + :vartype allow_claim: bool + :ivar storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). + :vartype storage_type: str + :ivar environment_id: The resource ID of the environment that contains this virtual machine, if + any. + :vartype environment_id: str + :ivar data_disk_parameters: New or existing data disks to attach to the virtual machine after creation. - :type data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskPropertiesFragment] - :param schedule_parameters: Virtual Machine schedules to be created. - :type schedule_parameters: - list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameterFragment] - :param last_known_power_state: Last known compute power state captured in DTL. - :type last_known_power_state: str + :vartype data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskProperties] + :ivar schedule_parameters: Virtual Machine schedules to be created. + :vartype schedule_parameters: list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameter] """ _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'bulk_creation_parameters': {'key': 'properties.bulkCreationParameters', 'type': 'BulkCreationParameters'}, 'notes': {'key': 'properties.notes', 'type': 'str'}, 'owner_object_id': {'key': 'properties.ownerObjectId', 'type': 'str'}, 'owner_user_principal_name': {'key': 'properties.ownerUserPrincipalName', 'type': 'str'}, - 'created_by_user_id': {'key': 'properties.createdByUserId', 'type': 'str'}, - 'created_by_user': {'key': 'properties.createdByUser', 'type': 'str'}, 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'compute_id': {'key': 'properties.computeId', 'type': 'str'}, 'custom_image_id': {'key': 'properties.customImageId', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, 'size': {'key': 'properties.size', 'type': 'str'}, 'user_name': {'key': 'properties.userName', 'type': 'str'}, 'password': {'key': 'properties.password', 'type': 'str'}, 'ssh_key': {'key': 'properties.sshKey', 'type': 'str'}, 'is_authentication_with_ssh_key': {'key': 'properties.isAuthenticationWithSshKey', 'type': 'bool'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, 'lab_subnet_name': {'key': 'properties.labSubnetName', 'type': 'str'}, 'lab_virtual_network_id': {'key': 'properties.labVirtualNetworkId', 'type': 'str'}, 'disallow_public_ip_address': {'key': 'properties.disallowPublicIpAddress', 'type': 'bool'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[ArtifactInstallPropertiesFragment]'}, - 'artifact_deployment_status': {'key': 'properties.artifactDeploymentStatus', 'type': 'ArtifactDeploymentStatusPropertiesFragment'}, - 'gallery_image_reference': {'key': 'properties.galleryImageReference', 'type': 'GalleryImageReferenceFragment'}, + 'artifacts': {'key': 'properties.artifacts', 'type': '[ArtifactInstallProperties]'}, + 'gallery_image_reference': {'key': 'properties.galleryImageReference', 'type': 'GalleryImageReference'}, 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterfacePropertiesFragment'}, + 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterfaceProperties'}, 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, 'allow_claim': {'key': 'properties.allowClaim', 'type': 'bool'}, 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, - 'virtual_machine_creation_source': {'key': 'properties.virtualMachineCreationSource', 'type': 'str'}, 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, - 'data_disk_parameters': {'key': 'properties.dataDiskParameters', 'type': '[DataDiskPropertiesFragment]'}, - 'schedule_parameters': {'key': 'properties.scheduleParameters', 'type': '[ScheduleCreationParameterFragment]'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, + 'data_disk_parameters': {'key': 'properties.dataDiskParameters', 'type': '[DataDiskProperties]'}, + 'schedule_parameters': {'key': 'properties.scheduleParameters', 'type': '[ScheduleCreationParameter]'}, } def __init__( self, *, + name: Optional[str] = None, + location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, + bulk_creation_parameters: Optional["BulkCreationParameters"] = None, notes: Optional[str] = None, - owner_object_id: Optional[str] = None, + owner_object_id: Optional[str] = "dynamicValue", owner_user_principal_name: Optional[str] = None, - created_by_user_id: Optional[str] = None, - created_by_user: Optional[str] = None, created_date: Optional[datetime.datetime] = None, - compute_id: Optional[str] = None, custom_image_id: Optional[str] = None, - os_type: Optional[str] = None, size: Optional[str] = None, user_name: Optional[str] = None, password: Optional[str] = None, ssh_key: Optional[str] = None, is_authentication_with_ssh_key: Optional[bool] = None, - fqdn: Optional[str] = None, lab_subnet_name: Optional[str] = None, lab_virtual_network_id: Optional[str] = None, - disallow_public_ip_address: Optional[bool] = None, - artifacts: Optional[List["ArtifactInstallPropertiesFragment"]] = None, - artifact_deployment_status: Optional["ArtifactDeploymentStatusPropertiesFragment"] = None, - gallery_image_reference: Optional["GalleryImageReferenceFragment"] = None, + disallow_public_ip_address: Optional[bool] = False, + artifacts: Optional[List["ArtifactInstallProperties"]] = None, + gallery_image_reference: Optional["GalleryImageReference"] = None, plan_id: Optional[str] = None, - network_interface: Optional["NetworkInterfacePropertiesFragment"] = None, + network_interface: Optional["NetworkInterfaceProperties"] = None, expiration_date: Optional[datetime.datetime] = None, - allow_claim: Optional[bool] = None, - storage_type: Optional[str] = None, - virtual_machine_creation_source: Optional[Union[str, "VirtualMachineCreationSource"]] = None, + allow_claim: Optional[bool] = False, + storage_type: Optional[str] = "labStorageType", environment_id: Optional[str] = None, - data_disk_parameters: Optional[List["DataDiskPropertiesFragment"]] = None, - schedule_parameters: Optional[List["ScheduleCreationParameterFragment"]] = None, - last_known_power_state: Optional[str] = None, + data_disk_parameters: Optional[List["DataDiskProperties"]] = None, + schedule_parameters: Optional[List["ScheduleCreationParameter"]] = None, **kwargs ): - super(LabVirtualMachineFragment, self).__init__(tags=tags, **kwargs) + """ + :keyword name: The name of the virtual machine or environment. + :paramtype name: str + :keyword location: The location of the new virtual machine or environment. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword bulk_creation_parameters: The number of virtual machine instances to create. + :paramtype bulk_creation_parameters: ~azure.mgmt.devtestlabs.models.BulkCreationParameters + :keyword notes: The notes of the virtual machine. + :paramtype notes: str + :keyword owner_object_id: The object identifier of the owner of the virtual machine. + :paramtype owner_object_id: str + :keyword owner_user_principal_name: The user principal name of the virtual machine owner. + :paramtype owner_user_principal_name: str + :keyword created_date: The creation date of the virtual machine. + :paramtype created_date: ~datetime.datetime + :keyword custom_image_id: The custom image identifier of the virtual machine. + :paramtype custom_image_id: str + :keyword size: The size of the virtual machine. + :paramtype size: str + :keyword user_name: The user name of the virtual machine. + :paramtype user_name: str + :keyword password: The password of the virtual machine administrator. + :paramtype password: str + :keyword ssh_key: The SSH key of the virtual machine administrator. + :paramtype ssh_key: str + :keyword is_authentication_with_ssh_key: Indicates whether this virtual machine uses an SSH key + for authentication. + :paramtype is_authentication_with_ssh_key: bool + :keyword lab_subnet_name: The lab subnet name of the virtual machine. + :paramtype lab_subnet_name: str + :keyword lab_virtual_network_id: The lab virtual network identifier of the virtual machine. + :paramtype lab_virtual_network_id: str + :keyword disallow_public_ip_address: Indicates whether the virtual machine is to be created + without a public IP address. + :paramtype disallow_public_ip_address: bool + :keyword artifacts: The artifacts to be installed on the virtual machine. + :paramtype artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] + :keyword gallery_image_reference: The Microsoft Azure Marketplace image reference of the + virtual machine. + :paramtype gallery_image_reference: ~azure.mgmt.devtestlabs.models.GalleryImageReference + :keyword plan_id: The id of the plan associated with the virtual machine image. + :paramtype plan_id: str + :keyword network_interface: The network interface properties. + :paramtype network_interface: ~azure.mgmt.devtestlabs.models.NetworkInterfaceProperties + :keyword expiration_date: The expiration date for VM. + :paramtype expiration_date: ~datetime.datetime + :keyword allow_claim: Indicates whether another user can take ownership of the virtual machine. + :paramtype allow_claim: bool + :keyword storage_type: Storage type to use for virtual machine (i.e. Standard, Premium). + :paramtype storage_type: str + :keyword environment_id: The resource ID of the environment that contains this virtual machine, + if any. + :paramtype environment_id: str + :keyword data_disk_parameters: New or existing data disks to attach to the virtual machine + after creation. + :paramtype data_disk_parameters: list[~azure.mgmt.devtestlabs.models.DataDiskProperties] + :keyword schedule_parameters: Virtual Machine schedules to be created. + :paramtype schedule_parameters: list[~azure.mgmt.devtestlabs.models.ScheduleCreationParameter] + """ + super(LabVirtualMachineCreationParameter, self).__init__(**kwargs) + self.name = name + self.location = location + self.tags = tags + self.bulk_creation_parameters = bulk_creation_parameters self.notes = notes self.owner_object_id = owner_object_id self.owner_user_principal_name = owner_user_principal_name - self.created_by_user_id = created_by_user_id - self.created_by_user = created_by_user self.created_date = created_date - self.compute_id = compute_id self.custom_image_id = custom_image_id - self.os_type = os_type self.size = size self.user_name = user_name self.password = password self.ssh_key = ssh_key self.is_authentication_with_ssh_key = is_authentication_with_ssh_key - self.fqdn = fqdn self.lab_subnet_name = lab_subnet_name self.lab_virtual_network_id = lab_virtual_network_id self.disallow_public_ip_address = disallow_public_ip_address self.artifacts = artifacts - self.artifact_deployment_status = artifact_deployment_status self.gallery_image_reference = gallery_image_reference self.plan_id = plan_id self.network_interface = network_interface self.expiration_date = expiration_date self.allow_claim = allow_claim self.storage_type = storage_type - self.virtual_machine_creation_source = virtual_machine_creation_source self.environment_id = environment_id self.data_disk_parameters = data_disk_parameters self.schedule_parameters = schedule_parameters - self.last_known_power_state = last_known_power_state -class LabVirtualMachineList(msrest.serialization.Model): - """The response of a list operation. +class LabVirtualMachineFragment(UpdateResource): + """A virtual machine. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.LabVirtualMachine] - :param next_link: Link for next set of results. - :type next_link: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LabVirtualMachine]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, *, - value: Optional[List["LabVirtualMachine"]] = None, - next_link: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, **kwargs ): - super(LabVirtualMachineList, self).__init__(**kwargs) - self.value = value - self.next_link = next_link + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ + super(LabVirtualMachineFragment, self).__init__(tags=tags, **kwargs) -class LinuxOsInfo(msrest.serialization.Model): - """Information about a Linux OS. +class LabVirtualMachineList(msrest.serialization.Model): + """The response of a list operation. - :param linux_os_state: The state of the Linux OS (i.e. NonDeprovisioned, DeprovisionRequested, - DeprovisionApplied). Possible values include: "NonDeprovisioned", "DeprovisionRequested", - "DeprovisionApplied". - :type linux_os_state: str or ~azure.mgmt.devtestlabs.models.LinuxOsState + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.LabVirtualMachine] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { - 'linux_os_state': {'key': 'linuxOsState', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[LabVirtualMachine]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, *, - linux_os_state: Optional[Union[str, "LinuxOsState"]] = None, + value: Optional[List["LabVirtualMachine"]] = None, + next_link: Optional[str] = None, **kwargs ): - super(LinuxOsInfo, self).__init__(**kwargs) - self.linux_os_state = linux_os_state + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.LabVirtualMachine] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ + super(LabVirtualMachineList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link -class LinuxOsInfoFragment(msrest.serialization.Model): +class LinuxOsInfo(msrest.serialization.Model): """Information about a Linux OS. - :param linux_os_state: The state of the Linux OS (i.e. NonDeprovisioned, DeprovisionRequested, + :ivar linux_os_state: The state of the Linux OS (i.e. NonDeprovisioned, DeprovisionRequested, DeprovisionApplied). Possible values include: "NonDeprovisioned", "DeprovisionRequested", "DeprovisionApplied". - :type linux_os_state: str or ~azure.mgmt.devtestlabs.models.LinuxOsState + :vartype linux_os_state: str or ~azure.mgmt.devtestlabs.models.LinuxOsState """ _attribute_map = { @@ -4661,34 +4036,40 @@ def __init__( linux_os_state: Optional[Union[str, "LinuxOsState"]] = None, **kwargs ): - super(LinuxOsInfoFragment, self).__init__(**kwargs) + """ + :keyword linux_os_state: The state of the Linux OS (i.e. NonDeprovisioned, + DeprovisionRequested, DeprovisionApplied). Possible values include: "NonDeprovisioned", + "DeprovisionRequested", "DeprovisionApplied". + :paramtype linux_os_state: str or ~azure.mgmt.devtestlabs.models.LinuxOsState + """ + super(LinuxOsInfo, self).__init__(**kwargs) self.linux_os_state = linux_os_state class NetworkInterfaceProperties(msrest.serialization.Model): """Properties of a network interface. - :param virtual_network_id: The resource ID of the virtual network. - :type virtual_network_id: str - :param subnet_id: The resource ID of the sub net. - :type subnet_id: str - :param public_ip_address_id: The resource ID of the public IP address. - :type public_ip_address_id: str - :param public_ip_address: The public IP address. - :type public_ip_address: str - :param private_ip_address: The private IP address. - :type private_ip_address: str - :param dns_name: The DNS name. - :type dns_name: str - :param rdp_authority: The RdpAuthority property is a server DNS host name or IP address - followed by the service port number for RDP (Remote Desktop Protocol). - :type rdp_authority: str - :param ssh_authority: The SshAuthority property is a server DNS host name or IP address - followed by the service port number for SSH. - :type ssh_authority: str - :param shared_public_ip_address_configuration: The configuration for sharing a public IP - address across multiple virtual machines. - :type shared_public_ip_address_configuration: + :ivar virtual_network_id: The resource ID of the virtual network. + :vartype virtual_network_id: str + :ivar subnet_id: The resource ID of the sub net. + :vartype subnet_id: str + :ivar public_ip_address_id: The resource ID of the public IP address. + :vartype public_ip_address_id: str + :ivar public_ip_address: The public IP address. + :vartype public_ip_address: str + :ivar private_ip_address: The private IP address. + :vartype private_ip_address: str + :ivar dns_name: The DNS name. + :vartype dns_name: str + :ivar rdp_authority: The RdpAuthority property is a server DNS host name or IP address followed + by the service port number for RDP (Remote Desktop Protocol). + :vartype rdp_authority: str + :ivar ssh_authority: The SshAuthority property is a server DNS host name or IP address followed + by the service port number for SSH. + :vartype ssh_authority: str + :ivar shared_public_ip_address_configuration: The configuration for sharing a public IP address + across multiple virtual machines. + :vartype shared_public_ip_address_configuration: ~azure.mgmt.devtestlabs.models.SharedPublicIpAddressConfiguration """ @@ -4718,6 +4099,30 @@ def __init__( shared_public_ip_address_configuration: Optional["SharedPublicIpAddressConfiguration"] = None, **kwargs ): + """ + :keyword virtual_network_id: The resource ID of the virtual network. + :paramtype virtual_network_id: str + :keyword subnet_id: The resource ID of the sub net. + :paramtype subnet_id: str + :keyword public_ip_address_id: The resource ID of the public IP address. + :paramtype public_ip_address_id: str + :keyword public_ip_address: The public IP address. + :paramtype public_ip_address: str + :keyword private_ip_address: The private IP address. + :paramtype private_ip_address: str + :keyword dns_name: The DNS name. + :paramtype dns_name: str + :keyword rdp_authority: The RdpAuthority property is a server DNS host name or IP address + followed by the service port number for RDP (Remote Desktop Protocol). + :paramtype rdp_authority: str + :keyword ssh_authority: The SshAuthority property is a server DNS host name or IP address + followed by the service port number for SSH. + :paramtype ssh_authority: str + :keyword shared_public_ip_address_configuration: The configuration for sharing a public IP + address across multiple virtual machines. + :paramtype shared_public_ip_address_configuration: + ~azure.mgmt.devtestlabs.models.SharedPublicIpAddressConfiguration + """ super(NetworkInterfaceProperties, self).__init__(**kwargs) self.virtual_network_id = virtual_network_id self.subnet_id = subnet_id @@ -4730,71 +4135,6 @@ def __init__( self.shared_public_ip_address_configuration = shared_public_ip_address_configuration -class NetworkInterfacePropertiesFragment(msrest.serialization.Model): - """Properties of a network interface. - - :param virtual_network_id: The resource ID of the virtual network. - :type virtual_network_id: str - :param subnet_id: The resource ID of the sub net. - :type subnet_id: str - :param public_ip_address_id: The resource ID of the public IP address. - :type public_ip_address_id: str - :param public_ip_address: The public IP address. - :type public_ip_address: str - :param private_ip_address: The private IP address. - :type private_ip_address: str - :param dns_name: The DNS name. - :type dns_name: str - :param rdp_authority: The RdpAuthority property is a server DNS host name or IP address - followed by the service port number for RDP (Remote Desktop Protocol). - :type rdp_authority: str - :param ssh_authority: The SshAuthority property is a server DNS host name or IP address - followed by the service port number for SSH. - :type ssh_authority: str - :param shared_public_ip_address_configuration: The configuration for sharing a public IP - address across multiple virtual machines. - :type shared_public_ip_address_configuration: - ~azure.mgmt.devtestlabs.models.SharedPublicIpAddressConfigurationFragment - """ - - _attribute_map = { - 'virtual_network_id': {'key': 'virtualNetworkId', 'type': 'str'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'public_ip_address_id': {'key': 'publicIpAddressId', 'type': 'str'}, - 'public_ip_address': {'key': 'publicIpAddress', 'type': 'str'}, - 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, - 'dns_name': {'key': 'dnsName', 'type': 'str'}, - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, - 'shared_public_ip_address_configuration': {'key': 'sharedPublicIpAddressConfiguration', 'type': 'SharedPublicIpAddressConfigurationFragment'}, - } - - def __init__( - self, - *, - virtual_network_id: Optional[str] = None, - subnet_id: Optional[str] = None, - public_ip_address_id: Optional[str] = None, - public_ip_address: Optional[str] = None, - private_ip_address: Optional[str] = None, - dns_name: Optional[str] = None, - rdp_authority: Optional[str] = None, - ssh_authority: Optional[str] = None, - shared_public_ip_address_configuration: Optional["SharedPublicIpAddressConfigurationFragment"] = None, - **kwargs - ): - super(NetworkInterfacePropertiesFragment, self).__init__(**kwargs) - self.virtual_network_id = virtual_network_id - self.subnet_id = subnet_id - self.public_ip_address_id = public_ip_address_id - self.public_ip_address = public_ip_address - self.private_ip_address = private_ip_address - self.dns_name = dns_name - self.rdp_authority = rdp_authority - self.ssh_authority = ssh_authority - self.shared_public_ip_address_configuration = shared_public_ip_address_configuration - - class NotificationChannel(Resource): """A notification. @@ -4806,22 +4146,22 @@ class NotificationChannel(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param web_hook_url: The webhook URL to send notifications to. - :type web_hook_url: str - :param email_recipient: The email recipient to send notifications to (can be a list of semi- - colon separated email addresses). - :type email_recipient: str - :param notification_locale: The locale to use when sending a notification (fallback for + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar web_hook_url: The webhook URL to send notifications to. + :vartype web_hook_url: str + :ivar email_recipient: The email recipient to send notifications to (can be a list of + semi-colon separated email addresses). + :vartype email_recipient: str + :ivar notification_locale: The locale to use when sending a notification (fallback for unsupported languages is EN). - :type notification_locale: str - :param description: Description of notification. - :type description: str - :param events: The list of event for which this notification is enabled. - :type events: list[~azure.mgmt.devtestlabs.models.Event] + :vartype notification_locale: str + :ivar description: Description of notification. + :vartype description: str + :ivar events: The list of event for which this notification is enabled. + :vartype events: list[~azure.mgmt.devtestlabs.models.Event] :ivar created_date: The creation date of the notification channel. :vartype created_date: ~datetime.datetime :ivar provisioning_state: The provisioning status of the resource. @@ -4867,6 +4207,24 @@ def __init__( events: Optional[List["Event"]] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword web_hook_url: The webhook URL to send notifications to. + :paramtype web_hook_url: str + :keyword email_recipient: The email recipient to send notifications to (can be a list of + semi-colon separated email addresses). + :paramtype email_recipient: str + :keyword notification_locale: The locale to use when sending a notification (fallback for + unsupported languages is EN). + :paramtype notification_locale: str + :keyword description: Description of notification. + :paramtype description: str + :keyword events: The list of event for which this notification is enabled. + :paramtype events: list[~azure.mgmt.devtestlabs.models.Event] + """ super(NotificationChannel, self).__init__(location=location, tags=tags, **kwargs) self.web_hook_url = web_hook_url self.email_recipient = email_recipient @@ -4881,57 +4239,34 @@ def __init__( class NotificationChannelFragment(UpdateResource): """A notification. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param web_hook_url: The webhook URL to send notifications to. - :type web_hook_url: str - :param email_recipient: The email recipient to send notifications to (can be a list of semi- - colon separated email addresses). - :type email_recipient: str - :param notification_locale: The locale to use when sending a notification (fallback for - unsupported languages is EN). - :type notification_locale: str - :param description: Description of notification. - :type description: str - :param events: The list of event for which this notification is enabled. - :type events: list[~azure.mgmt.devtestlabs.models.EventFragment] + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'web_hook_url': {'key': 'properties.webHookUrl', 'type': 'str'}, - 'email_recipient': {'key': 'properties.emailRecipient', 'type': 'str'}, - 'notification_locale': {'key': 'properties.notificationLocale', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'events': {'key': 'properties.events', 'type': '[EventFragment]'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - web_hook_url: Optional[str] = None, - email_recipient: Optional[str] = None, - notification_locale: Optional[str] = None, - description: Optional[str] = None, - events: Optional[List["EventFragment"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(NotificationChannelFragment, self).__init__(tags=tags, **kwargs) - self.web_hook_url = web_hook_url - self.email_recipient = email_recipient - self.notification_locale = notification_locale - self.description = description - self.events = events class NotificationChannelList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.NotificationChannel] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.NotificationChannel] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -4946,6 +4281,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.NotificationChannel] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(NotificationChannelList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -4954,19 +4295,19 @@ def __init__( class NotificationSettings(msrest.serialization.Model): """Notification settings for a schedule. - :param status: If notifications are enabled for this schedule (i.e. Enabled, Disabled). - Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param time_in_minutes: Time in minutes before event at which notification will be sent. - :type time_in_minutes: int - :param webhook_url: The webhook URL to which the notification will be sent. - :type webhook_url: str - :param email_recipient: The email recipient to send notifications to (can be a list of semi- - colon separated email addresses). - :type email_recipient: str - :param notification_locale: The locale to use when sending a notification (fallback for + :ivar status: If notifications are enabled for this schedule (i.e. Enabled, Disabled). Possible + values include: "Enabled", "Disabled". + :vartype status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :ivar time_in_minutes: Time in minutes before event at which notification will be sent. + :vartype time_in_minutes: int + :ivar webhook_url: The webhook URL to which the notification will be sent. + :vartype webhook_url: str + :ivar email_recipient: The email recipient to send notifications to (can be a list of + semi-colon separated email addresses). + :vartype email_recipient: str + :ivar notification_locale: The locale to use when sending a notification (fallback for unsupported languages is EN). - :type notification_locale: str + :vartype notification_locale: str """ _attribute_map = { @@ -4987,6 +4328,21 @@ def __init__( notification_locale: Optional[str] = None, **kwargs ): + """ + :keyword status: If notifications are enabled for this schedule (i.e. Enabled, Disabled). + Possible values include: "Enabled", "Disabled". + :paramtype status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :keyword time_in_minutes: Time in minutes before event at which notification will be sent. + :paramtype time_in_minutes: int + :keyword webhook_url: The webhook URL to which the notification will be sent. + :paramtype webhook_url: str + :keyword email_recipient: The email recipient to send notifications to (can be a list of + semi-colon separated email addresses). + :paramtype email_recipient: str + :keyword notification_locale: The locale to use when sending a notification (fallback for + unsupported languages is EN). + :paramtype notification_locale: str + """ super(NotificationSettings, self).__init__(**kwargs) self.status = status self.time_in_minutes = time_in_minutes @@ -4995,58 +4351,14 @@ def __init__( self.notification_locale = notification_locale -class NotificationSettingsFragment(msrest.serialization.Model): - """Notification settings for a schedule. - - :param status: If notifications are enabled for this schedule (i.e. Enabled, Disabled). - Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param time_in_minutes: Time in minutes before event at which notification will be sent. - :type time_in_minutes: int - :param webhook_url: The webhook URL to which the notification will be sent. - :type webhook_url: str - :param email_recipient: The email recipient to send notifications to (can be a list of semi- - colon separated email addresses). - :type email_recipient: str - :param notification_locale: The locale to use when sending a notification (fallback for - unsupported languages is EN). - :type notification_locale: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'time_in_minutes': {'key': 'timeInMinutes', 'type': 'int'}, - 'webhook_url': {'key': 'webhookUrl', 'type': 'str'}, - 'email_recipient': {'key': 'emailRecipient', 'type': 'str'}, - 'notification_locale': {'key': 'notificationLocale', 'type': 'str'}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "EnableStatus"]] = None, - time_in_minutes: Optional[int] = None, - webhook_url: Optional[str] = None, - email_recipient: Optional[str] = None, - notification_locale: Optional[str] = None, - **kwargs - ): - super(NotificationSettingsFragment, self).__init__(**kwargs) - self.status = status - self.time_in_minutes = time_in_minutes - self.webhook_url = webhook_url - self.email_recipient = email_recipient - self.notification_locale = notification_locale - - class NotifyParameters(msrest.serialization.Model): """Properties for generating a Notification. - :param event_name: The type of event (i.e. AutoShutdown, Cost). Possible values include: + :ivar event_name: The type of event (i.e. AutoShutdown, Cost). Possible values include: "AutoShutdown", "Cost". - :type event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType - :param json_payload: Properties for the notification in json format. - :type json_payload: str + :vartype event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType + :ivar json_payload: Properties for the notification in json format. + :vartype json_payload: str """ _attribute_map = { @@ -5061,6 +4373,13 @@ def __init__( json_payload: Optional[str] = None, **kwargs ): + """ + :keyword event_name: The type of event (i.e. AutoShutdown, Cost). Possible values include: + "AutoShutdown", "Cost". + :paramtype event_name: str or ~azure.mgmt.devtestlabs.models.NotificationChannelEventType + :keyword json_payload: Properties for the notification in json format. + :paramtype json_payload: str + """ super(NotifyParameters, self).__init__(**kwargs) self.event_name = event_name self.json_payload = json_payload @@ -5069,10 +4388,10 @@ def __init__( class OperationError(msrest.serialization.Model): """Error details for the operation in case of a failure. - :param code: The error code of the operation error. - :type code: str - :param message: The error message of the operation error. - :type message: str + :ivar code: The error code of the operation error. + :vartype code: str + :ivar message: The error message of the operation error. + :vartype message: str """ _attribute_map = { @@ -5087,6 +4406,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: The error code of the operation error. + :paramtype code: str + :keyword message: The error message of the operation error. + :paramtype message: str + """ super(OperationError, self).__init__(**kwargs) self.code = code self.message = message @@ -5095,10 +4420,10 @@ def __init__( class OperationMetadata(msrest.serialization.Model): """The REST API operation supported by DevTestLab ResourceProvider. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that describes the operations. - :type display: ~azure.mgmt.devtestlabs.models.OperationMetadataDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that describes the operations. + :vartype display: ~azure.mgmt.devtestlabs.models.OperationMetadataDisplay """ _attribute_map = { @@ -5113,6 +4438,12 @@ def __init__( display: Optional["OperationMetadataDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that describes the operations. + :paramtype display: ~azure.mgmt.devtestlabs.models.OperationMetadataDisplay + """ super(OperationMetadata, self).__init__(**kwargs) self.name = name self.display = display @@ -5121,14 +4452,14 @@ def __init__( class OperationMetadataDisplay(msrest.serialization.Model): """The object that describes the operations. - :param provider: Friendly name of the resource provider. - :type provider: str - :param resource: Resource type on which the operation is performed. - :type resource: str - :param operation: Operation type: read, write, delete, listKeys/action, etc. - :type operation: str - :param description: Friendly name of the operation. - :type description: str + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + :ivar resource: Resource type on which the operation is performed. + :vartype resource: str + :ivar operation: Operation type: read, write, delete, listKeys/action, etc. + :vartype operation: str + :ivar description: Friendly name of the operation. + :vartype description: str """ _attribute_map = { @@ -5147,6 +4478,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Friendly name of the resource provider. + :paramtype provider: str + :keyword resource: Resource type on which the operation is performed. + :paramtype resource: str + :keyword operation: Operation type: read, write, delete, listKeys/action, etc. + :paramtype operation: str + :keyword description: Friendly name of the operation. + :paramtype description: str + """ super(OperationMetadataDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -5157,21 +4498,22 @@ def __init__( class OperationResult(msrest.serialization.Model): """An Operation Result. - :param status: The operation status. - :type status: str - :param status_code: The status code for the operation. Possible values include: "Continue", + :ivar status: The operation status. + :vartype status: str + :ivar status_code: The status code for the operation. Possible values include: "Continue", "SwitchingProtocols", "OK", "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", - "ResetContent", "PartialContent", "MultipleChoices", "MovedPermanently", "Redirect", - "SeeOther", "NotModified", "UseProxy", "Unused", "TemporaryRedirect", "BadRequest", - "Unauthorized", "PaymentRequired", "Forbidden", "NotFound", "MethodNotAllowed", - "NotAcceptable", "ProxyAuthenticationRequired", "RequestTimeout", "Conflict", "Gone", - "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", - "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", - "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", + "ResetContent", "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", + "Found", "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", + "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", + "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", + "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", + "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", + "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", + "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", "HttpVersionNotSupported". - :type status_code: str or ~azure.mgmt.devtestlabs.models.HttpStatusCode - :param error: Error details for the operation in case of a failure. - :type error: ~azure.mgmt.devtestlabs.models.OperationError + :vartype status_code: str or ~azure.mgmt.devtestlabs.models.HttpStatusCode + :ivar error: Error details for the operation in case of a failure. + :vartype error: ~azure.mgmt.devtestlabs.models.OperationError """ _attribute_map = { @@ -5188,6 +4530,24 @@ def __init__( error: Optional["OperationError"] = None, **kwargs ): + """ + :keyword status: The operation status. + :paramtype status: str + :keyword status_code: The status code for the operation. Possible values include: "Continue", + "SwitchingProtocols", "OK", "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", + "ResetContent", "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", + "Found", "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", + "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", + "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", + "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", + "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", + "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", + "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", + "HttpVersionNotSupported". + :paramtype status_code: str or ~azure.mgmt.devtestlabs.models.HttpStatusCode + :keyword error: Error details for the operation in case of a failure. + :paramtype error: ~azure.mgmt.devtestlabs.models.OperationError + """ super(OperationResult, self).__init__(**kwargs) self.status = status self.status_code = status_code @@ -5197,10 +4557,10 @@ def __init__( class ParameterInfo(msrest.serialization.Model): """Information about an artifact's parameter. - :param name: The name of the artifact parameter. - :type name: str - :param value: The value of the artifact parameter. - :type value: str + :ivar name: The name of the artifact parameter. + :vartype name: str + :ivar value: The value of the artifact parameter. + :vartype value: str """ _attribute_map = { @@ -5215,6 +4575,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the artifact parameter. + :paramtype name: str + :keyword value: The value of the artifact parameter. + :paramtype value: str + """ super(ParameterInfo, self).__init__(**kwargs) self.name = name self.value = value @@ -5223,10 +4589,10 @@ def __init__( class ParametersValueFileInfo(msrest.serialization.Model): """A file containing a set of parameter values for an ARM template. - :param file_name: File name. - :type file_name: str - :param parameters_value_info: Contents of the file. - :type parameters_value_info: object + :ivar file_name: File name. + :vartype file_name: str + :ivar parameters_value_info: Contents of the file. + :vartype parameters_value_info: any """ _attribute_map = { @@ -5238,9 +4604,15 @@ def __init__( self, *, file_name: Optional[str] = None, - parameters_value_info: Optional[object] = None, + parameters_value_info: Optional[Any] = None, **kwargs ): + """ + :keyword file_name: File name. + :paramtype file_name: str + :keyword parameters_value_info: Contents of the file. + :paramtype parameters_value_info: any + """ super(ParametersValueFileInfo, self).__init__(**kwargs) self.file_name = file_name self.parameters_value_info = parameters_value_info @@ -5249,8 +4621,8 @@ def __init__( class PercentageCostThresholdProperties(msrest.serialization.Model): """Properties of a percentage cost threshold. - :param threshold_value: The cost threshold value. - :type threshold_value: float + :ivar threshold_value: The cost threshold value. + :vartype threshold_value: float """ _attribute_map = { @@ -5263,6 +4635,10 @@ def __init__( threshold_value: Optional[float] = None, **kwargs ): + """ + :keyword threshold_value: The cost threshold value. + :paramtype threshold_value: float + """ super(PercentageCostThresholdProperties, self).__init__(**kwargs) self.threshold_value = threshold_value @@ -5278,27 +4654,27 @@ class Policy(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param description: The description of the policy. - :type description: str - :param status: The status of the policy. Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.PolicyStatus - :param fact_name: The fact name of the policy (e.g. LabVmCount, LabVmSize, MaxVmsAllowedPerLab, + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar description: The description of the policy. + :vartype description: str + :ivar status: The status of the policy. Possible values include: "Enabled", "Disabled". + :vartype status: str or ~azure.mgmt.devtestlabs.models.PolicyStatus + :ivar fact_name: The fact name of the policy (e.g. LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. Possible values include: "UserOwnedLabVmCount", "UserOwnedLabPremiumVmCount", "LabVmCount", "LabPremiumVmCount", "LabVmSize", "GalleryImage", "UserOwnedLabVmCountInSubnet", "LabTargetCost", "EnvironmentTemplate", "ScheduleEditPermission". - :type fact_name: str or ~azure.mgmt.devtestlabs.models.PolicyFactName - :param fact_data: The fact data of the policy. - :type fact_data: str - :param threshold: The threshold of the policy (i.e. a number for MaxValuePolicy, and a JSON + :vartype fact_name: str or ~azure.mgmt.devtestlabs.models.PolicyFactName + :ivar fact_data: The fact data of the policy. + :vartype fact_data: str + :ivar threshold: The threshold of the policy (i.e. a number for MaxValuePolicy, and a JSON array of values for AllowedValuesPolicy). - :type threshold: str - :param evaluator_type: The evaluator type of the policy (i.e. AllowedValuesPolicy, + :vartype threshold: str + :ivar evaluator_type: The evaluator type of the policy (i.e. AllowedValuesPolicy, MaxValuePolicy). Possible values include: "AllowedValuesPolicy", "MaxValuePolicy". - :type evaluator_type: str or ~azure.mgmt.devtestlabs.models.PolicyEvaluatorType + :vartype evaluator_type: str or ~azure.mgmt.devtestlabs.models.PolicyEvaluatorType :ivar created_date: The creation date of the policy. :vartype created_date: ~datetime.datetime :ivar provisioning_state: The provisioning status of the resource. @@ -5346,6 +4722,30 @@ def __init__( evaluator_type: Optional[Union[str, "PolicyEvaluatorType"]] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword description: The description of the policy. + :paramtype description: str + :keyword status: The status of the policy. Possible values include: "Enabled", "Disabled". + :paramtype status: str or ~azure.mgmt.devtestlabs.models.PolicyStatus + :keyword fact_name: The fact name of the policy (e.g. LabVmCount, LabVmSize, + MaxVmsAllowedPerLab, etc. Possible values include: "UserOwnedLabVmCount", + "UserOwnedLabPremiumVmCount", "LabVmCount", "LabPremiumVmCount", "LabVmSize", "GalleryImage", + "UserOwnedLabVmCountInSubnet", "LabTargetCost", "EnvironmentTemplate", + "ScheduleEditPermission". + :paramtype fact_name: str or ~azure.mgmt.devtestlabs.models.PolicyFactName + :keyword fact_data: The fact data of the policy. + :paramtype fact_data: str + :keyword threshold: The threshold of the policy (i.e. a number for MaxValuePolicy, and a JSON + array of values for AllowedValuesPolicy). + :paramtype threshold: str + :keyword evaluator_type: The evaluator type of the policy (i.e. AllowedValuesPolicy, + MaxValuePolicy). Possible values include: "AllowedValuesPolicy", "MaxValuePolicy". + :paramtype evaluator_type: str or ~azure.mgmt.devtestlabs.models.PolicyEvaluatorType + """ super(Policy, self).__init__(location=location, tags=tags, **kwargs) self.description = description self.status = status @@ -5361,65 +4761,34 @@ def __init__( class PolicyFragment(UpdateResource): """A Policy. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param description: The description of the policy. - :type description: str - :param status: The status of the policy. Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.PolicyStatus - :param fact_name: The fact name of the policy (e.g. LabVmCount, LabVmSize, MaxVmsAllowedPerLab, - etc. Possible values include: "UserOwnedLabVmCount", "UserOwnedLabPremiumVmCount", - "LabVmCount", "LabPremiumVmCount", "LabVmSize", "GalleryImage", "UserOwnedLabVmCountInSubnet", - "LabTargetCost", "EnvironmentTemplate", "ScheduleEditPermission". - :type fact_name: str or ~azure.mgmt.devtestlabs.models.PolicyFactName - :param fact_data: The fact data of the policy. - :type fact_data: str - :param threshold: The threshold of the policy (i.e. a number for MaxValuePolicy, and a JSON - array of values for AllowedValuesPolicy). - :type threshold: str - :param evaluator_type: The evaluator type of the policy (i.e. AllowedValuesPolicy, - MaxValuePolicy). Possible values include: "AllowedValuesPolicy", "MaxValuePolicy". - :type evaluator_type: str or ~azure.mgmt.devtestlabs.models.PolicyEvaluatorType + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'fact_name': {'key': 'properties.factName', 'type': 'str'}, - 'fact_data': {'key': 'properties.factData', 'type': 'str'}, - 'threshold': {'key': 'properties.threshold', 'type': 'str'}, - 'evaluator_type': {'key': 'properties.evaluatorType', 'type': 'str'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - status: Optional[Union[str, "PolicyStatus"]] = None, - fact_name: Optional[Union[str, "PolicyFactName"]] = None, - fact_data: Optional[str] = None, - threshold: Optional[str] = None, - evaluator_type: Optional[Union[str, "PolicyEvaluatorType"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(PolicyFragment, self).__init__(tags=tags, **kwargs) - self.description = description - self.status = status - self.fact_name = fact_name - self.fact_data = fact_data - self.threshold = threshold - self.evaluator_type = evaluator_type class PolicyList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Policy] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.Policy] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -5434,6 +4803,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.Policy] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(PolicyList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -5442,11 +4817,11 @@ def __init__( class PolicySetResult(msrest.serialization.Model): """Result of a policy set evaluation. - :param has_error: A value indicating whether this policy set evaluation has discovered + :ivar has_error: A value indicating whether this policy set evaluation has discovered violations. - :type has_error: bool - :param policy_violations: The list of policy violations. - :type policy_violations: list[~azure.mgmt.devtestlabs.models.PolicyViolation] + :vartype has_error: bool + :ivar policy_violations: The list of policy violations. + :vartype policy_violations: list[~azure.mgmt.devtestlabs.models.PolicyViolation] """ _attribute_map = { @@ -5461,6 +4836,13 @@ def __init__( policy_violations: Optional[List["PolicyViolation"]] = None, **kwargs ): + """ + :keyword has_error: A value indicating whether this policy set evaluation has discovered + violations. + :paramtype has_error: bool + :keyword policy_violations: The list of policy violations. + :paramtype policy_violations: list[~azure.mgmt.devtestlabs.models.PolicyViolation] + """ super(PolicySetResult, self).__init__(**kwargs) self.has_error = has_error self.policy_violations = policy_violations @@ -5469,10 +4851,10 @@ def __init__( class PolicyViolation(msrest.serialization.Model): """Policy violation. - :param code: The code of the policy violation. - :type code: str - :param message: The message of the policy violation. - :type message: str + :ivar code: The code of the policy violation. + :vartype code: str + :ivar message: The message of the policy violation. + :vartype message: str """ _attribute_map = { @@ -5487,6 +4869,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: The code of the policy violation. + :paramtype code: str + :keyword message: The message of the policy violation. + :paramtype message: str + """ super(PolicyViolation, self).__init__(**kwargs) self.code = code self.message = message @@ -5495,10 +4883,10 @@ def __init__( class Port(msrest.serialization.Model): """Properties of a network port. - :param transport_protocol: Protocol type of the port. Possible values include: "Tcp", "Udp". - :type transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol - :param backend_port: Backend port of the target virtual machine. - :type backend_port: int + :ivar transport_protocol: Protocol type of the port. Possible values include: "Tcp", "Udp". + :vartype transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol + :ivar backend_port: Backend port of the target virtual machine. + :vartype backend_port: int """ _attribute_map = { @@ -5513,44 +4901,24 @@ def __init__( backend_port: Optional[int] = None, **kwargs ): + """ + :keyword transport_protocol: Protocol type of the port. Possible values include: "Tcp", "Udp". + :paramtype transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol + :keyword backend_port: Backend port of the target virtual machine. + :paramtype backend_port: int + """ super(Port, self).__init__(**kwargs) self.transport_protocol = transport_protocol self.backend_port = backend_port -class PortFragment(msrest.serialization.Model): - """Properties of a network port. - - :param transport_protocol: Protocol type of the port. Possible values include: "Tcp", "Udp". - :type transport_protocol: str or ~azure.mgmt.devtestlabs.models.TransportProtocol - :param backend_port: Backend port of the target virtual machine. - :type backend_port: int - """ - - _attribute_map = { - 'transport_protocol': {'key': 'transportProtocol', 'type': 'str'}, - 'backend_port': {'key': 'backendPort', 'type': 'int'}, - } - - def __init__( - self, - *, - transport_protocol: Optional[Union[str, "TransportProtocol"]] = None, - backend_port: Optional[int] = None, - **kwargs - ): - super(PortFragment, self).__init__(**kwargs) - self.transport_protocol = transport_protocol - self.backend_port = backend_port - - class ProviderOperationResult(msrest.serialization.Model): """Result of the request to list REST API operations. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of operations supported by the resource provider. - :type value: list[~azure.mgmt.devtestlabs.models.OperationMetadata] + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.devtestlabs.models.OperationMetadata] :ivar next_link: URL to get the next set of operation list results if there are any. :vartype next_link: str """ @@ -5570,6 +4938,10 @@ def __init__( value: Optional[List["OperationMetadata"]] = None, **kwargs ): + """ + :keyword value: List of operations supported by the resource provider. + :paramtype value: list[~azure.mgmt.devtestlabs.models.OperationMetadata] + """ super(ProviderOperationResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -5578,8 +4950,8 @@ def __init__( class RdpConnection(msrest.serialization.Model): """Represents a .rdp file. - :param contents: The contents of the .rdp file. - :type contents: str + :ivar contents: The contents of the .rdp file. + :vartype contents: str """ _attribute_map = { @@ -5592,6 +4964,10 @@ def __init__( contents: Optional[str] = None, **kwargs ): + """ + :keyword contents: The contents of the .rdp file. + :paramtype contents: str + """ super(RdpConnection, self).__init__(**kwargs) self.contents = contents @@ -5599,8 +4975,8 @@ def __init__( class ResizeLabVirtualMachineProperties(msrest.serialization.Model): """Request body for resizing a virtual machine. - :param size: Specifies the size of the virtual machine. - :type size: str + :ivar size: Specifies the size of the virtual machine. + :vartype size: str """ _attribute_map = { @@ -5613,6 +4989,10 @@ def __init__( size: Optional[str] = None, **kwargs ): + """ + :keyword size: Specifies the size of the virtual machine. + :paramtype size: str + """ super(ResizeLabVirtualMachineProperties, self).__init__(**kwargs) self.size = size @@ -5620,12 +5000,12 @@ def __init__( class RetargetScheduleProperties(msrest.serialization.Model): """Properties for retargeting a virtual machine schedule. - :param current_resource_id: The resource Id of the virtual machine on which the schedule + :ivar current_resource_id: The resource Id of the virtual machine on which the schedule operates. - :type current_resource_id: str - :param target_resource_id: The resource Id of the virtual machine that the schedule should be + :vartype current_resource_id: str + :ivar target_resource_id: The resource Id of the virtual machine that the schedule should be retargeted to. - :type target_resource_id: str + :vartype target_resource_id: str """ _attribute_map = { @@ -5640,6 +5020,14 @@ def __init__( target_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword current_resource_id: The resource Id of the virtual machine on which the schedule + operates. + :paramtype current_resource_id: str + :keyword target_resource_id: The resource Id of the virtual machine that the schedule should be + retargeted to. + :paramtype target_resource_id: str + """ super(RetargetScheduleProperties, self).__init__(**kwargs) self.current_resource_id = current_resource_id self.target_resource_id = target_resource_id @@ -5656,32 +5044,32 @@ class Schedule(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). - :type task_type: str - :param weekly_recurrence: If the schedule will occur only some days of the week, specify the + :vartype status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :ivar task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). + :vartype task_type: str + :ivar weekly_recurrence: If the schedule will occur only some days of the week, specify the weekly recurrence. - :type weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetails - :param daily_recurrence: If the schedule will occur once each day of the week, specify the - daily recurrence. - :type daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetails - :param hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly + :vartype weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetails + :ivar daily_recurrence: If the schedule will occur once each day of the week, specify the daily recurrence. - :type hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetails - :param time_zone_id: The time zone ID (e.g. Pacific Standard time). - :type time_zone_id: str - :param notification_settings: Notification settings. - :type notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettings + :vartype daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetails + :ivar hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly + recurrence. + :vartype hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetails + :ivar time_zone_id: The time zone ID (e.g. Pacific Standard time). + :vartype time_zone_id: str + :ivar notification_settings: Notification settings. + :vartype notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettings :ivar created_date: The creation date of the schedule. :vartype created_date: ~datetime.datetime - :param target_resource_id: The resource ID to which the schedule belongs. - :type target_resource_id: str + :ivar target_resource_id: The resource ID to which the schedule belongs. + :vartype target_resource_id: str :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -5731,85 +5119,33 @@ def __init__( target_resource_id: Optional[str] = None, **kwargs ): - super(Schedule, self).__init__(location=location, tags=tags, **kwargs) - self.status = status - self.task_type = task_type - self.weekly_recurrence = weekly_recurrence - self.daily_recurrence = daily_recurrence - self.hourly_recurrence = hourly_recurrence - self.time_zone_id = time_zone_id - self.notification_settings = notification_settings - self.created_date = None - self.target_resource_id = target_resource_id - self.provisioning_state = None - self.unique_identifier = None - - -class ScheduleCreationParameter(msrest.serialization.Model): - """Properties for creating a schedule. - - :param name: The name of the virtual machine or environment. - :type name: str - :param location: The location of the new virtual machine or environment. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: - "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). - :type task_type: str - :param weekly_recurrence: If the schedule will occur only some days of the week, specify the - weekly recurrence. - :type weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetails - :param daily_recurrence: If the schedule will occur once each day of the week, specify the - daily recurrence. - :type daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetails - :param hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly - recurrence. - :type hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetails - :param time_zone_id: The time zone ID (e.g. Pacific Standard time). - :type time_zone_id: str - :param notification_settings: Notification settings. - :type notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettings - :param target_resource_id: The resource ID to which the schedule belongs. - :type target_resource_id: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'task_type': {'key': 'properties.taskType', 'type': 'str'}, - 'weekly_recurrence': {'key': 'properties.weeklyRecurrence', 'type': 'WeekDetails'}, - 'daily_recurrence': {'key': 'properties.dailyRecurrence', 'type': 'DayDetails'}, - 'hourly_recurrence': {'key': 'properties.hourlyRecurrence', 'type': 'HourDetails'}, - 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, - 'notification_settings': {'key': 'properties.notificationSettings', 'type': 'NotificationSettings'}, - 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "EnableStatus"]] = None, - task_type: Optional[str] = None, - weekly_recurrence: Optional["WeekDetails"] = None, - daily_recurrence: Optional["DayDetails"] = None, - hourly_recurrence: Optional["HourDetails"] = None, - time_zone_id: Optional[str] = None, - notification_settings: Optional["NotificationSettings"] = None, - target_resource_id: Optional[str] = None, - **kwargs - ): - super(ScheduleCreationParameter, self).__init__(**kwargs) - self.name = name - self.location = location - self.tags = tags + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: + "Enabled", "Disabled". + :paramtype status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :keyword task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). + :paramtype task_type: str + :keyword weekly_recurrence: If the schedule will occur only some days of the week, specify the + weekly recurrence. + :paramtype weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetails + :keyword daily_recurrence: If the schedule will occur once each day of the week, specify the + daily recurrence. + :paramtype daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetails + :keyword hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly + recurrence. + :paramtype hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetails + :keyword time_zone_id: The time zone ID (e.g. Pacific Standard time). + :paramtype time_zone_id: str + :keyword notification_settings: Notification settings. + :paramtype notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettings + :keyword target_resource_id: The resource ID to which the schedule belongs. + :paramtype target_resource_id: str + """ + super(Schedule, self).__init__(location=location, tags=tags, **kwargs) self.status = status self.task_type = task_type self.weekly_recurrence = weekly_recurrence @@ -5817,51 +5153,60 @@ def __init__( self.hourly_recurrence = hourly_recurrence self.time_zone_id = time_zone_id self.notification_settings = notification_settings + self.created_date = None self.target_resource_id = target_resource_id + self.provisioning_state = None + self.unique_identifier = None -class ScheduleCreationParameterFragment(msrest.serialization.Model): +class ScheduleCreationParameter(msrest.serialization.Model): """Properties for creating a schedule. - :param name: The name of the virtual machine or environment. - :type name: str - :param location: The location of the new virtual machine or environment. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the virtual machine or environment. + :vartype name: str + :ivar location: The location of the new virtual machine or environment. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). - :type task_type: str - :param weekly_recurrence: If the schedule will occur only some days of the week, specify the + :vartype status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :ivar task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). + :vartype task_type: str + :ivar weekly_recurrence: If the schedule will occur only some days of the week, specify the weekly recurrence. - :type weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetailsFragment - :param daily_recurrence: If the schedule will occur once each day of the week, specify the - daily recurrence. - :type daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetailsFragment - :param hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly + :vartype weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetails + :ivar daily_recurrence: If the schedule will occur once each day of the week, specify the daily + recurrence. + :vartype daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetails + :ivar hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly recurrence. - :type hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetailsFragment - :param time_zone_id: The time zone ID (e.g. Pacific Standard time). - :type time_zone_id: str - :param notification_settings: Notification settings. - :type notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettingsFragment - :param target_resource_id: The resource ID to which the schedule belongs. - :type target_resource_id: str + :vartype hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetails + :ivar time_zone_id: The time zone ID (e.g. Pacific Standard time). + :vartype time_zone_id: str + :ivar notification_settings: Notification settings. + :vartype notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettings + :ivar target_resource_id: The resource ID to which the schedule belongs. + :vartype target_resource_id: str """ + _validation = { + 'location': {'readonly': True}, + } + _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'status': {'key': 'properties.status', 'type': 'str'}, 'task_type': {'key': 'properties.taskType', 'type': 'str'}, - 'weekly_recurrence': {'key': 'properties.weeklyRecurrence', 'type': 'WeekDetailsFragment'}, - 'daily_recurrence': {'key': 'properties.dailyRecurrence', 'type': 'DayDetailsFragment'}, - 'hourly_recurrence': {'key': 'properties.hourlyRecurrence', 'type': 'HourDetailsFragment'}, + 'weekly_recurrence': {'key': 'properties.weeklyRecurrence', 'type': 'WeekDetails'}, + 'daily_recurrence': {'key': 'properties.dailyRecurrence', 'type': 'DayDetails'}, + 'hourly_recurrence': {'key': 'properties.hourlyRecurrence', 'type': 'HourDetails'}, 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, - 'notification_settings': {'key': 'properties.notificationSettings', 'type': 'NotificationSettingsFragment'}, + 'notification_settings': {'key': 'properties.notificationSettings', 'type': 'NotificationSettings'}, 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, } @@ -5869,21 +5214,46 @@ def __init__( self, *, name: Optional[str] = None, - location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, status: Optional[Union[str, "EnableStatus"]] = None, task_type: Optional[str] = None, - weekly_recurrence: Optional["WeekDetailsFragment"] = None, - daily_recurrence: Optional["DayDetailsFragment"] = None, - hourly_recurrence: Optional["HourDetailsFragment"] = None, + weekly_recurrence: Optional["WeekDetails"] = None, + daily_recurrence: Optional["DayDetails"] = None, + hourly_recurrence: Optional["HourDetails"] = None, time_zone_id: Optional[str] = None, - notification_settings: Optional["NotificationSettingsFragment"] = None, + notification_settings: Optional["NotificationSettings"] = None, target_resource_id: Optional[str] = None, **kwargs ): - super(ScheduleCreationParameterFragment, self).__init__(**kwargs) + """ + :keyword name: The name of the virtual machine or environment. + :paramtype name: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: + "Enabled", "Disabled". + :paramtype status: str or ~azure.mgmt.devtestlabs.models.EnableStatus + :keyword task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). + :paramtype task_type: str + :keyword weekly_recurrence: If the schedule will occur only some days of the week, specify the + weekly recurrence. + :paramtype weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetails + :keyword daily_recurrence: If the schedule will occur once each day of the week, specify the + daily recurrence. + :paramtype daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetails + :keyword hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly + recurrence. + :paramtype hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetails + :keyword time_zone_id: The time zone ID (e.g. Pacific Standard time). + :paramtype time_zone_id: str + :keyword notification_settings: Notification settings. + :paramtype notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettings + :keyword target_resource_id: The resource ID to which the schedule belongs. + :paramtype target_resource_id: str + """ + super(ScheduleCreationParameter, self).__init__(**kwargs) self.name = name - self.location = location + self.location = None self.tags = tags self.status = status self.task_type = task_type @@ -5898,74 +5268,34 @@ def __init__( class ScheduleFragment(UpdateResource): """A schedule. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param status: The status of the schedule (i.e. Enabled, Disabled). Possible values include: - "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.EnableStatus - :param task_type: The task type of the schedule (e.g. LabVmsShutdownTask, LabVmAutoStart). - :type task_type: str - :param weekly_recurrence: If the schedule will occur only some days of the week, specify the - weekly recurrence. - :type weekly_recurrence: ~azure.mgmt.devtestlabs.models.WeekDetailsFragment - :param daily_recurrence: If the schedule will occur once each day of the week, specify the - daily recurrence. - :type daily_recurrence: ~azure.mgmt.devtestlabs.models.DayDetailsFragment - :param hourly_recurrence: If the schedule will occur multiple times a day, specify the hourly - recurrence. - :type hourly_recurrence: ~azure.mgmt.devtestlabs.models.HourDetailsFragment - :param time_zone_id: The time zone ID (e.g. Pacific Standard time). - :type time_zone_id: str - :param notification_settings: Notification settings. - :type notification_settings: ~azure.mgmt.devtestlabs.models.NotificationSettingsFragment - :param target_resource_id: The resource ID to which the schedule belongs. - :type target_resource_id: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'task_type': {'key': 'properties.taskType', 'type': 'str'}, - 'weekly_recurrence': {'key': 'properties.weeklyRecurrence', 'type': 'WeekDetailsFragment'}, - 'daily_recurrence': {'key': 'properties.dailyRecurrence', 'type': 'DayDetailsFragment'}, - 'hourly_recurrence': {'key': 'properties.hourlyRecurrence', 'type': 'HourDetailsFragment'}, - 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, - 'notification_settings': {'key': 'properties.notificationSettings', 'type': 'NotificationSettingsFragment'}, - 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "EnableStatus"]] = None, - task_type: Optional[str] = None, - weekly_recurrence: Optional["WeekDetailsFragment"] = None, - daily_recurrence: Optional["DayDetailsFragment"] = None, - hourly_recurrence: Optional["HourDetailsFragment"] = None, - time_zone_id: Optional[str] = None, - notification_settings: Optional["NotificationSettingsFragment"] = None, - target_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(ScheduleFragment, self).__init__(tags=tags, **kwargs) - self.status = status - self.task_type = task_type - self.weekly_recurrence = weekly_recurrence - self.daily_recurrence = daily_recurrence - self.hourly_recurrence = hourly_recurrence - self.time_zone_id = time_zone_id - self.notification_settings = notification_settings - self.target_resource_id = target_resource_id class ScheduleList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Schedule] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.Schedule] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -5980,6 +5310,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.Schedule] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(ScheduleList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -5996,12 +5332,12 @@ class Secret(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param value: The value of the secret for secret creation. - :type value: str + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar value: The value of the secret for secret creation. + :vartype value: str :ivar provisioning_state: The provisioning status of the resource. :vartype provisioning_state: str :ivar unique_identifier: The unique immutable identifier of a resource (Guid). @@ -6035,6 +5371,14 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword value: The value of the secret for secret creation. + :paramtype value: str + """ super(Secret, self).__init__(location=location, tags=tags, **kwargs) self.value = value self.provisioning_state = None @@ -6044,35 +5388,34 @@ def __init__( class SecretFragment(UpdateResource): """A secret. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param value: The value of the secret for secret creation. - :type value: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'value': {'key': 'properties.value', 'type': 'str'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - value: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(SecretFragment, self).__init__(tags=tags, **kwargs) - self.value = value class SecretList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.Secret] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.Secret] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -6087,6 +5430,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.Secret] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(SecretList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -6103,15 +5452,15 @@ class ServiceFabric(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param external_service_fabric_id: The backing service fabric resource's id. - :type external_service_fabric_id: str - :param environment_id: The resource id of the environment under which the service fabric + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar external_service_fabric_id: The backing service fabric resource's id. + :vartype external_service_fabric_id: str + :ivar environment_id: The resource id of the environment under which the service fabric resource is present. - :type environment_id: str + :vartype environment_id: str :ivar applicable_schedule: The applicable schedule for the virtual machine. :vartype applicable_schedule: ~azure.mgmt.devtestlabs.models.ApplicableSchedule :ivar provisioning_state: The provisioning status of the resource. @@ -6151,6 +5500,17 @@ def __init__( environment_id: Optional[str] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword external_service_fabric_id: The backing service fabric resource's id. + :paramtype external_service_fabric_id: str + :keyword environment_id: The resource id of the environment under which the service fabric + resource is present. + :paramtype environment_id: str + """ super(ServiceFabric, self).__init__(location=location, tags=tags, **kwargs) self.external_service_fabric_id = external_service_fabric_id self.environment_id = environment_id @@ -6162,41 +5522,34 @@ def __init__( class ServiceFabricFragment(UpdateResource): """A Service Fabric. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param external_service_fabric_id: The backing service fabric resource's id. - :type external_service_fabric_id: str - :param environment_id: The resource id of the environment under which the service fabric - resource is present. - :type environment_id: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'external_service_fabric_id': {'key': 'properties.externalServiceFabricId', 'type': 'str'}, - 'environment_id': {'key': 'properties.environmentId', 'type': 'str'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - external_service_fabric_id: Optional[str] = None, - environment_id: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(ServiceFabricFragment, self).__init__(tags=tags, **kwargs) - self.external_service_fabric_id = external_service_fabric_id - self.environment_id = environment_id class ServiceFabricList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.ServiceFabric] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.ServiceFabric] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -6211,6 +5564,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.ServiceFabric] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(ServiceFabricList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -6227,12 +5586,12 @@ class ServiceRunner(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.devtestlabs.models.IdentityProperties + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.devtestlabs.models.IdentityProperties """ _validation = { @@ -6258,81 +5617,104 @@ def __init__( identity: Optional["IdentityProperties"] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.devtestlabs.models.IdentityProperties + """ super(ServiceRunner, self).__init__(location=location, tags=tags, **kwargs) self.identity = identity -class SharedPublicIpAddressConfiguration(msrest.serialization.Model): - """Properties of a virtual machine that determine how it is connected to a load balancer. +class ServiceRunnerList(msrest.serialization.Model): + """The response of a list operation. - :param inbound_nat_rules: The incoming NAT rules. - :type inbound_nat_rules: list[~azure.mgmt.devtestlabs.models.InboundNatRule] + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.ServiceRunner] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { - 'inbound_nat_rules': {'key': 'inboundNatRules', 'type': '[InboundNatRule]'}, + 'value': {'key': 'value', 'type': '[ServiceRunner]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, *, - inbound_nat_rules: Optional[List["InboundNatRule"]] = None, + value: Optional[List["ServiceRunner"]] = None, + next_link: Optional[str] = None, **kwargs ): - super(SharedPublicIpAddressConfiguration, self).__init__(**kwargs) - self.inbound_nat_rules = inbound_nat_rules + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.ServiceRunner] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ + super(ServiceRunnerList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link -class SharedPublicIpAddressConfigurationFragment(msrest.serialization.Model): +class SharedPublicIpAddressConfiguration(msrest.serialization.Model): """Properties of a virtual machine that determine how it is connected to a load balancer. - :param inbound_nat_rules: The incoming NAT rules. - :type inbound_nat_rules: list[~azure.mgmt.devtestlabs.models.InboundNatRuleFragment] + :ivar inbound_nat_rules: The incoming NAT rules. + :vartype inbound_nat_rules: list[~azure.mgmt.devtestlabs.models.InboundNatRule] """ _attribute_map = { - 'inbound_nat_rules': {'key': 'inboundNatRules', 'type': '[InboundNatRuleFragment]'}, + 'inbound_nat_rules': {'key': 'inboundNatRules', 'type': '[InboundNatRule]'}, } def __init__( self, *, - inbound_nat_rules: Optional[List["InboundNatRuleFragment"]] = None, + inbound_nat_rules: Optional[List["InboundNatRule"]] = None, **kwargs ): - super(SharedPublicIpAddressConfigurationFragment, self).__init__(**kwargs) + """ + :keyword inbound_nat_rules: The incoming NAT rules. + :paramtype inbound_nat_rules: list[~azure.mgmt.devtestlabs.models.InboundNatRule] + """ + super(SharedPublicIpAddressConfiguration, self).__init__(**kwargs) self.inbound_nat_rules = inbound_nat_rules class ShutdownNotificationContent(msrest.serialization.Model): """The contents of a shutdown notification. Webhooks can use this type to deserialize the request body when they get notified of an imminent shutdown. - :param skip_url: The URL to skip auto-shutdown. - :type skip_url: str - :param delay_url60: The URL to delay shutdown by 60 minutes. - :type delay_url60: str - :param delay_url120: The URL to delay shutdown by 2 hours. - :type delay_url120: str - :param vm_name: The virtual machine to be shut down. - :type vm_name: str - :param guid: The GUID for the virtual machine to be shut down. - :type guid: str - :param owner: The owner of the virtual machine. - :type owner: str - :param vm_url: The URL of the virtual machine. - :type vm_url: str - :param minutes_until_shutdown: Minutes remaining until shutdown. - :type minutes_until_shutdown: str - :param event_type: The event for which a notification will be sent. - :type event_type: str - :param text: The text for the notification. - :type text: str - :param subscription_id: The subscription ID for the schedule. - :type subscription_id: str - :param resource_group_name: The resource group name for the schedule. - :type resource_group_name: str - :param lab_name: The lab for the schedule. - :type lab_name: str + :ivar skip_url: The URL to skip auto-shutdown. + :vartype skip_url: str + :ivar delay_url60: The URL to delay shutdown by 60 minutes. + :vartype delay_url60: str + :ivar delay_url120: The URL to delay shutdown by 2 hours. + :vartype delay_url120: str + :ivar vm_name: The virtual machine to be shut down. + :vartype vm_name: str + :ivar guid: The GUID for the virtual machine to be shut down. + :vartype guid: str + :ivar owner: The owner of the virtual machine. + :vartype owner: str + :ivar vm_url: The URL of the virtual machine. + :vartype vm_url: str + :ivar minutes_until_shutdown: Minutes remaining until shutdown. + :vartype minutes_until_shutdown: str + :ivar event_type: The event for which a notification will be sent. + :vartype event_type: str + :ivar text: The text for the notification. + :vartype text: str + :ivar subscription_id: The subscription ID for the schedule. + :vartype subscription_id: str + :ivar resource_group_name: The resource group name for the schedule. + :vartype resource_group_name: str + :ivar lab_name: The lab for the schedule. + :vartype lab_name: str """ _attribute_map = { @@ -6369,6 +5751,34 @@ def __init__( lab_name: Optional[str] = None, **kwargs ): + """ + :keyword skip_url: The URL to skip auto-shutdown. + :paramtype skip_url: str + :keyword delay_url60: The URL to delay shutdown by 60 minutes. + :paramtype delay_url60: str + :keyword delay_url120: The URL to delay shutdown by 2 hours. + :paramtype delay_url120: str + :keyword vm_name: The virtual machine to be shut down. + :paramtype vm_name: str + :keyword guid: The GUID for the virtual machine to be shut down. + :paramtype guid: str + :keyword owner: The owner of the virtual machine. + :paramtype owner: str + :keyword vm_url: The URL of the virtual machine. + :paramtype vm_url: str + :keyword minutes_until_shutdown: Minutes remaining until shutdown. + :paramtype minutes_until_shutdown: str + :keyword event_type: The event for which a notification will be sent. + :paramtype event_type: str + :keyword text: The text for the notification. + :paramtype text: str + :keyword subscription_id: The subscription ID for the schedule. + :paramtype subscription_id: str + :keyword resource_group_name: The resource group name for the schedule. + :paramtype resource_group_name: str + :keyword lab_name: The lab for the schedule. + :paramtype lab_name: str + """ super(ShutdownNotificationContent, self).__init__(**kwargs) self.skip_url = skip_url self.delay_url60 = delay_url60 @@ -6388,13 +5798,13 @@ def __init__( class Subnet(msrest.serialization.Model): """Subnet information. - :param resource_id: The resource ID of the subnet. - :type resource_id: str - :param lab_subnet_name: The name of the subnet as seen in the lab. - :type lab_subnet_name: str - :param allow_public_ip: The permission policy of the subnet for allowing public IP addresses + :ivar resource_id: The resource ID of the subnet. + :vartype resource_id: str + :ivar lab_subnet_name: The name of the subnet as seen in the lab. + :vartype lab_subnet_name: str + :ivar allow_public_ip: The permission policy of the subnet for allowing public IP addresses (i.e. Allow, Deny)). Possible values include: "Default", "Deny", "Allow". - :type allow_public_ip: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType + :vartype allow_public_ip: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType """ _attribute_map = { @@ -6411,65 +5821,43 @@ def __init__( allow_public_ip: Optional[Union[str, "UsagePermissionType"]] = None, **kwargs ): + """ + :keyword resource_id: The resource ID of the subnet. + :paramtype resource_id: str + :keyword lab_subnet_name: The name of the subnet as seen in the lab. + :paramtype lab_subnet_name: str + :keyword allow_public_ip: The permission policy of the subnet for allowing public IP addresses + (i.e. Allow, Deny)). Possible values include: "Default", "Deny", "Allow". + :paramtype allow_public_ip: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType + """ super(Subnet, self).__init__(**kwargs) self.resource_id = resource_id self.lab_subnet_name = lab_subnet_name self.allow_public_ip = allow_public_ip -class SubnetFragment(msrest.serialization.Model): - """Subnet information. - - :param resource_id: The resource ID of the subnet. - :type resource_id: str - :param lab_subnet_name: The name of the subnet as seen in the lab. - :type lab_subnet_name: str - :param allow_public_ip: The permission policy of the subnet for allowing public IP addresses - (i.e. Allow, Deny)). Possible values include: "Default", "Deny", "Allow". - :type allow_public_ip: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'lab_subnet_name': {'key': 'labSubnetName', 'type': 'str'}, - 'allow_public_ip': {'key': 'allowPublicIp', 'type': 'str'}, - } - - def __init__( - self, - *, - resource_id: Optional[str] = None, - lab_subnet_name: Optional[str] = None, - allow_public_ip: Optional[Union[str, "UsagePermissionType"]] = None, - **kwargs - ): - super(SubnetFragment, self).__init__(**kwargs) - self.resource_id = resource_id - self.lab_subnet_name = lab_subnet_name - self.allow_public_ip = allow_public_ip - - class SubnetOverride(msrest.serialization.Model): """Property overrides on a subnet of a virtual network. - :param resource_id: The resource ID of the subnet. - :type resource_id: str - :param lab_subnet_name: The name given to the subnet within the lab. - :type lab_subnet_name: str - :param use_in_vm_creation_permission: Indicates whether this subnet can be used during virtual + :ivar resource_id: The resource ID of the subnet. + :vartype resource_id: str + :ivar lab_subnet_name: The name given to the subnet within the lab. + :vartype lab_subnet_name: str + :ivar use_in_vm_creation_permission: Indicates whether this subnet can be used during virtual machine creation (i.e. Allow, Deny). Possible values include: "Default", "Deny", "Allow". - :type use_in_vm_creation_permission: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType - :param use_public_ip_address_permission: Indicates whether public IP addresses can be assigned + :vartype use_in_vm_creation_permission: str or + ~azure.mgmt.devtestlabs.models.UsagePermissionType + :ivar use_public_ip_address_permission: Indicates whether public IP addresses can be assigned to virtual machines on this subnet (i.e. Allow, Deny). Possible values include: "Default", "Deny", "Allow". - :type use_public_ip_address_permission: str or + :vartype use_public_ip_address_permission: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType - :param shared_public_ip_address_configuration: Properties that virtual machines on this subnet + :ivar shared_public_ip_address_configuration: Properties that virtual machines on this subnet will share. - :type shared_public_ip_address_configuration: + :vartype shared_public_ip_address_configuration: ~azure.mgmt.devtestlabs.models.SubnetSharedPublicIpAddressConfiguration - :param virtual_network_pool_name: The virtual network pool associated with this subnet. - :type virtual_network_pool_name: str + :ivar virtual_network_pool_name: The virtual network pool associated with this subnet. + :vartype virtual_network_pool_name: str """ _attribute_map = { @@ -6492,6 +5880,28 @@ def __init__( virtual_network_pool_name: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: The resource ID of the subnet. + :paramtype resource_id: str + :keyword lab_subnet_name: The name given to the subnet within the lab. + :paramtype lab_subnet_name: str + :keyword use_in_vm_creation_permission: Indicates whether this subnet can be used during + virtual machine creation (i.e. Allow, Deny). Possible values include: "Default", "Deny", + "Allow". + :paramtype use_in_vm_creation_permission: str or + ~azure.mgmt.devtestlabs.models.UsagePermissionType + :keyword use_public_ip_address_permission: Indicates whether public IP addresses can be + assigned to virtual machines on this subnet (i.e. Allow, Deny). Possible values include: + "Default", "Deny", "Allow". + :paramtype use_public_ip_address_permission: str or + ~azure.mgmt.devtestlabs.models.UsagePermissionType + :keyword shared_public_ip_address_configuration: Properties that virtual machines on this + subnet will share. + :paramtype shared_public_ip_address_configuration: + ~azure.mgmt.devtestlabs.models.SubnetSharedPublicIpAddressConfiguration + :keyword virtual_network_pool_name: The virtual network pool associated with this subnet. + :paramtype virtual_network_pool_name: str + """ super(SubnetOverride, self).__init__(**kwargs) self.resource_id = resource_id self.lab_subnet_name = lab_subnet_name @@ -6501,63 +5911,11 @@ def __init__( self.virtual_network_pool_name = virtual_network_pool_name -class SubnetOverrideFragment(msrest.serialization.Model): - """Property overrides on a subnet of a virtual network. - - :param resource_id: The resource ID of the subnet. - :type resource_id: str - :param lab_subnet_name: The name given to the subnet within the lab. - :type lab_subnet_name: str - :param use_in_vm_creation_permission: Indicates whether this subnet can be used during virtual - machine creation (i.e. Allow, Deny). Possible values include: "Default", "Deny", "Allow". - :type use_in_vm_creation_permission: str or ~azure.mgmt.devtestlabs.models.UsagePermissionType - :param use_public_ip_address_permission: Indicates whether public IP addresses can be assigned - to virtual machines on this subnet (i.e. Allow, Deny). Possible values include: "Default", - "Deny", "Allow". - :type use_public_ip_address_permission: str or - ~azure.mgmt.devtestlabs.models.UsagePermissionType - :param shared_public_ip_address_configuration: Properties that virtual machines on this subnet - will share. - :type shared_public_ip_address_configuration: - ~azure.mgmt.devtestlabs.models.SubnetSharedPublicIpAddressConfigurationFragment - :param virtual_network_pool_name: The virtual network pool associated with this subnet. - :type virtual_network_pool_name: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'lab_subnet_name': {'key': 'labSubnetName', 'type': 'str'}, - 'use_in_vm_creation_permission': {'key': 'useInVmCreationPermission', 'type': 'str'}, - 'use_public_ip_address_permission': {'key': 'usePublicIpAddressPermission', 'type': 'str'}, - 'shared_public_ip_address_configuration': {'key': 'sharedPublicIpAddressConfiguration', 'type': 'SubnetSharedPublicIpAddressConfigurationFragment'}, - 'virtual_network_pool_name': {'key': 'virtualNetworkPoolName', 'type': 'str'}, - } - - def __init__( - self, - *, - resource_id: Optional[str] = None, - lab_subnet_name: Optional[str] = None, - use_in_vm_creation_permission: Optional[Union[str, "UsagePermissionType"]] = None, - use_public_ip_address_permission: Optional[Union[str, "UsagePermissionType"]] = None, - shared_public_ip_address_configuration: Optional["SubnetSharedPublicIpAddressConfigurationFragment"] = None, - virtual_network_pool_name: Optional[str] = None, - **kwargs - ): - super(SubnetOverrideFragment, self).__init__(**kwargs) - self.resource_id = resource_id - self.lab_subnet_name = lab_subnet_name - self.use_in_vm_creation_permission = use_in_vm_creation_permission - self.use_public_ip_address_permission = use_public_ip_address_permission - self.shared_public_ip_address_configuration = shared_public_ip_address_configuration - self.virtual_network_pool_name = virtual_network_pool_name - - class SubnetSharedPublicIpAddressConfiguration(msrest.serialization.Model): """Configuration for public IP address sharing. - :param allowed_ports: Backend ports that virtual machines on this subnet are allowed to expose. - :type allowed_ports: list[~azure.mgmt.devtestlabs.models.Port] + :ivar allowed_ports: Backend ports that virtual machines on this subnet are allowed to expose. + :vartype allowed_ports: list[~azure.mgmt.devtestlabs.models.Port] """ _attribute_map = { @@ -6570,46 +5928,30 @@ def __init__( allowed_ports: Optional[List["Port"]] = None, **kwargs ): + """ + :keyword allowed_ports: Backend ports that virtual machines on this subnet are allowed to + expose. + :paramtype allowed_ports: list[~azure.mgmt.devtestlabs.models.Port] + """ super(SubnetSharedPublicIpAddressConfiguration, self).__init__(**kwargs) self.allowed_ports = allowed_ports -class SubnetSharedPublicIpAddressConfigurationFragment(msrest.serialization.Model): - """Configuration for public IP address sharing. - - :param allowed_ports: Backend ports that virtual machines on this subnet are allowed to expose. - :type allowed_ports: list[~azure.mgmt.devtestlabs.models.PortFragment] - """ - - _attribute_map = { - 'allowed_ports': {'key': 'allowedPorts', 'type': '[PortFragment]'}, - } - - def __init__( - self, - *, - allowed_ports: Optional[List["PortFragment"]] = None, - **kwargs - ): - super(SubnetSharedPublicIpAddressConfigurationFragment, self).__init__(**kwargs) - self.allowed_ports = allowed_ports - - class TargetCostProperties(msrest.serialization.Model): """Properties of a cost target. - :param status: Target cost status. Possible values include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.devtestlabs.models.TargetCostStatus - :param target: Lab target cost. - :type target: int - :param cost_thresholds: Cost thresholds. - :type cost_thresholds: list[~azure.mgmt.devtestlabs.models.CostThresholdProperties] - :param cycle_start_date_time: Reporting cycle start date. - :type cycle_start_date_time: ~datetime.datetime - :param cycle_end_date_time: Reporting cycle end date. - :type cycle_end_date_time: ~datetime.datetime - :param cycle_type: Reporting cycle type. Possible values include: "CalendarMonth", "Custom". - :type cycle_type: str or ~azure.mgmt.devtestlabs.models.ReportingCycleType + :ivar status: Target cost status. Possible values include: "Enabled", "Disabled". + :vartype status: str or ~azure.mgmt.devtestlabs.models.TargetCostStatus + :ivar target: Lab target cost. + :vartype target: int + :ivar cost_thresholds: Cost thresholds. + :vartype cost_thresholds: list[~azure.mgmt.devtestlabs.models.CostThresholdProperties] + :ivar cycle_start_date_time: Reporting cycle start date. + :vartype cycle_start_date_time: ~datetime.datetime + :ivar cycle_end_date_time: Reporting cycle end date. + :vartype cycle_end_date_time: ~datetime.datetime + :ivar cycle_type: Reporting cycle type. Possible values include: "CalendarMonth", "Custom". + :vartype cycle_type: str or ~azure.mgmt.devtestlabs.models.ReportingCycleType """ _attribute_map = { @@ -6632,6 +5974,20 @@ def __init__( cycle_type: Optional[Union[str, "ReportingCycleType"]] = None, **kwargs ): + """ + :keyword status: Target cost status. Possible values include: "Enabled", "Disabled". + :paramtype status: str or ~azure.mgmt.devtestlabs.models.TargetCostStatus + :keyword target: Lab target cost. + :paramtype target: int + :keyword cost_thresholds: Cost thresholds. + :paramtype cost_thresholds: list[~azure.mgmt.devtestlabs.models.CostThresholdProperties] + :keyword cycle_start_date_time: Reporting cycle start date. + :paramtype cycle_start_date_time: ~datetime.datetime + :keyword cycle_end_date_time: Reporting cycle end date. + :paramtype cycle_end_date_time: ~datetime.datetime + :keyword cycle_type: Reporting cycle type. Possible values include: "CalendarMonth", "Custom". + :paramtype cycle_type: str or ~azure.mgmt.devtestlabs.models.ReportingCycleType + """ super(TargetCostProperties, self).__init__(**kwargs) self.status = status self.target = target @@ -6652,14 +6008,14 @@ class User(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the user. - :type identity: ~azure.mgmt.devtestlabs.models.UserIdentity - :param secret_store: The secret store of the user. - :type secret_store: ~azure.mgmt.devtestlabs.models.UserSecretStore + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar identity: The identity of the user. + :vartype identity: ~azure.mgmt.devtestlabs.models.UserIdentity + :ivar secret_store: The secret store of the user. + :vartype secret_store: ~azure.mgmt.devtestlabs.models.UserSecretStore :ivar created_date: The creation date of the user profile. :vartype created_date: ~datetime.datetime :ivar provisioning_state: The provisioning status of the resource. @@ -6699,6 +6055,16 @@ def __init__( secret_store: Optional["UserSecretStore"] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the user. + :paramtype identity: ~azure.mgmt.devtestlabs.models.UserIdentity + :keyword secret_store: The secret store of the user. + :paramtype secret_store: ~azure.mgmt.devtestlabs.models.UserSecretStore + """ super(User, self).__init__(location=location, tags=tags, **kwargs) self.identity = identity self.secret_store = secret_store @@ -6710,48 +6076,42 @@ def __init__( class UserFragment(UpdateResource): """Profile of a lab user. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the user. - :type identity: ~azure.mgmt.devtestlabs.models.UserIdentityFragment - :param secret_store: The secret store of the user. - :type secret_store: ~azure.mgmt.devtestlabs.models.UserSecretStoreFragment + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'properties.identity', 'type': 'UserIdentityFragment'}, - 'secret_store': {'key': 'properties.secretStore', 'type': 'UserSecretStoreFragment'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["UserIdentityFragment"] = None, - secret_store: Optional["UserSecretStoreFragment"] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(UserFragment, self).__init__(tags=tags, **kwargs) - self.identity = identity - self.secret_store = secret_store class UserIdentity(msrest.serialization.Model): """Identity attributes of a lab user. - :param principal_name: Set to the principal name / UPN of the client JWT making the request. - :type principal_name: str - :param principal_id: Set to the principal Id of the client JWT making the request. Service + :ivar principal_name: Set to the principal name / UPN of the client JWT making the request. + :vartype principal_name: str + :ivar principal_id: Set to the principal Id of the client JWT making the request. Service principal will not have the principal Id. - :type principal_id: str - :param tenant_id: Set to the tenant ID of the client JWT making the request. - :type tenant_id: str - :param object_id: Set to the object Id of the client JWT making the request. Not all users have + :vartype principal_id: str + :ivar tenant_id: Set to the tenant ID of the client JWT making the request. + :vartype tenant_id: str + :ivar object_id: Set to the object Id of the client JWT making the request. Not all users have object Id. For CSP (reseller) scenarios for example, object Id is not available. - :type object_id: str - :param app_id: Set to the app Id of the client JWT making the request. - :type app_id: str + :vartype object_id: str + :ivar app_id: Set to the app Id of the client JWT making the request. + :vartype app_id: str """ _attribute_map = { @@ -6772,6 +6132,20 @@ def __init__( app_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_name: Set to the principal name / UPN of the client JWT making the request. + :paramtype principal_name: str + :keyword principal_id: Set to the principal Id of the client JWT making the request. Service + principal will not have the principal Id. + :paramtype principal_id: str + :keyword tenant_id: Set to the tenant ID of the client JWT making the request. + :paramtype tenant_id: str + :keyword object_id: Set to the object Id of the client JWT making the request. Not all users + have object Id. For CSP (reseller) scenarios for example, object Id is not available. + :paramtype object_id: str + :keyword app_id: Set to the app Id of the client JWT making the request. + :paramtype app_id: str + """ super(UserIdentity, self).__init__(**kwargs) self.principal_name = principal_name self.principal_id = principal_id @@ -6780,56 +6154,13 @@ def __init__( self.app_id = app_id -class UserIdentityFragment(msrest.serialization.Model): - """Identity attributes of a lab user. - - :param principal_name: Set to the principal name / UPN of the client JWT making the request. - :type principal_name: str - :param principal_id: Set to the principal Id of the client JWT making the request. Service - principal will not have the principal Id. - :type principal_id: str - :param tenant_id: Set to the tenant ID of the client JWT making the request. - :type tenant_id: str - :param object_id: Set to the object Id of the client JWT making the request. Not all users have - object Id. For CSP (reseller) scenarios for example, object Id is not available. - :type object_id: str - :param app_id: Set to the app Id of the client JWT making the request. - :type app_id: str - """ - - _attribute_map = { - 'principal_name': {'key': 'principalName', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'app_id': {'key': 'appId', 'type': 'str'}, - } - - def __init__( - self, - *, - principal_name: Optional[str] = None, - principal_id: Optional[str] = None, - tenant_id: Optional[str] = None, - object_id: Optional[str] = None, - app_id: Optional[str] = None, - **kwargs - ): - super(UserIdentityFragment, self).__init__(**kwargs) - self.principal_name = principal_name - self.principal_id = principal_id - self.tenant_id = tenant_id - self.object_id = object_id - self.app_id = app_id - - class UserList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.User] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.User] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -6844,6 +6175,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.User] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(UserList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -6852,10 +6189,10 @@ def __init__( class UserSecretStore(msrest.serialization.Model): """Properties of a user's secret store. - :param key_vault_uri: The URI of the user's Key vault. - :type key_vault_uri: str - :param key_vault_id: The ID of the user's Key vault. - :type key_vault_id: str + :ivar key_vault_uri: The URI of the user's Key vault. + :vartype key_vault_uri: str + :ivar key_vault_id: The ID of the user's Key vault. + :vartype key_vault_id: str """ _attribute_map = { @@ -6870,37 +6207,17 @@ def __init__( key_vault_id: Optional[str] = None, **kwargs ): + """ + :keyword key_vault_uri: The URI of the user's Key vault. + :paramtype key_vault_uri: str + :keyword key_vault_id: The ID of the user's Key vault. + :paramtype key_vault_id: str + """ super(UserSecretStore, self).__init__(**kwargs) self.key_vault_uri = key_vault_uri self.key_vault_id = key_vault_id -class UserSecretStoreFragment(msrest.serialization.Model): - """Properties of a user's secret store. - - :param key_vault_uri: The URI of the user's Key vault. - :type key_vault_uri: str - :param key_vault_id: The ID of the user's Key vault. - :type key_vault_id: str - """ - - _attribute_map = { - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, - } - - def __init__( - self, - *, - key_vault_uri: Optional[str] = None, - key_vault_id: Optional[str] = None, - **kwargs - ): - super(UserSecretStoreFragment, self).__init__(**kwargs) - self.key_vault_uri = key_vault_uri - self.key_vault_id = key_vault_id - - class VirtualNetwork(Resource): """A virtual network. @@ -6912,21 +6229,21 @@ class VirtualNetwork(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param allowed_subnets: The allowed subnets of the virtual network. - :type allowed_subnets: list[~azure.mgmt.devtestlabs.models.Subnet] - :param description: The description of the virtual network. - :type description: str - :param external_provider_resource_id: The Microsoft.Network resource identifier of the virtual + :ivar location: The location of the resource. + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar allowed_subnets: The allowed subnets of the virtual network. + :vartype allowed_subnets: list[~azure.mgmt.devtestlabs.models.Subnet] + :ivar description: The description of the virtual network. + :vartype description: str + :ivar external_provider_resource_id: The Microsoft.Network resource identifier of the virtual network. - :type external_provider_resource_id: str + :vartype external_provider_resource_id: str :ivar external_subnets: The external subnet properties. :vartype external_subnets: list[~azure.mgmt.devtestlabs.models.ExternalSubnet] - :param subnet_overrides: The subnet overrides of the virtual network. - :type subnet_overrides: list[~azure.mgmt.devtestlabs.models.SubnetOverride] + :ivar subnet_overrides: The subnet overrides of the virtual network. + :vartype subnet_overrides: list[~azure.mgmt.devtestlabs.models.SubnetOverride] :ivar created_date: The creation date of the virtual network. :vartype created_date: ~datetime.datetime :ivar provisioning_state: The provisioning status of the resource. @@ -6972,6 +6289,21 @@ def __init__( subnet_overrides: Optional[List["SubnetOverride"]] = None, **kwargs ): + """ + :keyword location: The location of the resource. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword allowed_subnets: The allowed subnets of the virtual network. + :paramtype allowed_subnets: list[~azure.mgmt.devtestlabs.models.Subnet] + :keyword description: The description of the virtual network. + :paramtype description: str + :keyword external_provider_resource_id: The Microsoft.Network resource identifier of the + virtual network. + :paramtype external_provider_resource_id: str + :keyword subnet_overrides: The subnet overrides of the virtual network. + :paramtype subnet_overrides: list[~azure.mgmt.devtestlabs.models.SubnetOverride] + """ super(VirtualNetwork, self).__init__(location=location, tags=tags, **kwargs) self.allowed_subnets = allowed_subnets self.description = description @@ -6986,51 +6318,34 @@ def __init__( class VirtualNetworkFragment(UpdateResource): """A virtual network. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param allowed_subnets: The allowed subnets of the virtual network. - :type allowed_subnets: list[~azure.mgmt.devtestlabs.models.SubnetFragment] - :param description: The description of the virtual network. - :type description: str - :param external_provider_resource_id: The Microsoft.Network resource identifier of the virtual - network. - :type external_provider_resource_id: str - :param subnet_overrides: The subnet overrides of the virtual network. - :type subnet_overrides: list[~azure.mgmt.devtestlabs.models.SubnetOverrideFragment] + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'allowed_subnets': {'key': 'properties.allowedSubnets', 'type': '[SubnetFragment]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'external_provider_resource_id': {'key': 'properties.externalProviderResourceId', 'type': 'str'}, - 'subnet_overrides': {'key': 'properties.subnetOverrides', 'type': '[SubnetOverrideFragment]'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - allowed_subnets: Optional[List["SubnetFragment"]] = None, - description: Optional[str] = None, - external_provider_resource_id: Optional[str] = None, - subnet_overrides: Optional[List["SubnetOverrideFragment"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(VirtualNetworkFragment, self).__init__(tags=tags, **kwargs) - self.allowed_subnets = allowed_subnets - self.description = description - self.external_provider_resource_id = external_provider_resource_id - self.subnet_overrides = subnet_overrides class VirtualNetworkList(msrest.serialization.Model): """The response of a list operation. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.devtestlabs.models.VirtualNetwork] - :param next_link: Link for next set of results. - :type next_link: str + :ivar value: Results of the list operation. + :vartype value: list[~azure.mgmt.devtestlabs.models.VirtualNetwork] + :ivar next_link: Link for next set of results. + :vartype next_link: str """ _attribute_map = { @@ -7045,6 +6360,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of the list operation. + :paramtype value: list[~azure.mgmt.devtestlabs.models.VirtualNetwork] + :keyword next_link: Link for next set of results. + :paramtype next_link: str + """ super(VirtualNetworkList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -7053,11 +6374,11 @@ def __init__( class WeekDetails(msrest.serialization.Model): """Properties of a weekly schedule. - :param weekdays: The days of the week for which the schedule is set (e.g. Sunday, Monday, + :ivar weekdays: The days of the week for which the schedule is set (e.g. Sunday, Monday, Tuesday, etc.). - :type weekdays: list[str] - :param time: The time of the day the schedule will occur. - :type time: str + :vartype weekdays: list[str] + :ivar time: The time of the day the schedule will occur. + :vartype time: str """ _attribute_map = { @@ -7072,45 +6393,25 @@ def __init__( time: Optional[str] = None, **kwargs ): + """ + :keyword weekdays: The days of the week for which the schedule is set (e.g. Sunday, Monday, + Tuesday, etc.). + :paramtype weekdays: list[str] + :keyword time: The time of the day the schedule will occur. + :paramtype time: str + """ super(WeekDetails, self).__init__(**kwargs) self.weekdays = weekdays self.time = time -class WeekDetailsFragment(msrest.serialization.Model): - """Properties of a weekly schedule. - - :param weekdays: The days of the week for which the schedule is set (e.g. Sunday, Monday, - Tuesday, etc.). - :type weekdays: list[str] - :param time: The time of the day the schedule will occur. - :type time: str - """ - - _attribute_map = { - 'weekdays': {'key': 'weekdays', 'type': '[str]'}, - 'time': {'key': 'time', 'type': 'str'}, - } - - def __init__( - self, - *, - weekdays: Optional[List[str]] = None, - time: Optional[str] = None, - **kwargs - ): - super(WeekDetailsFragment, self).__init__(**kwargs) - self.weekdays = weekdays - self.time = time - - class WindowsOsInfo(msrest.serialization.Model): """Information about a Windows OS. - :param windows_os_state: The state of the Windows OS (i.e. NonSysprepped, SysprepRequested, + :ivar windows_os_state: The state of the Windows OS (i.e. NonSysprepped, SysprepRequested, SysprepApplied). Possible values include: "NonSysprepped", "SysprepRequested", "SysprepApplied". - :type windows_os_state: str or ~azure.mgmt.devtestlabs.models.WindowsOsState + :vartype windows_os_state: str or ~azure.mgmt.devtestlabs.models.WindowsOsState """ _attribute_map = { @@ -7123,28 +6424,11 @@ def __init__( windows_os_state: Optional[Union[str, "WindowsOsState"]] = None, **kwargs ): + """ + :keyword windows_os_state: The state of the Windows OS (i.e. NonSysprepped, SysprepRequested, + SysprepApplied). Possible values include: "NonSysprepped", "SysprepRequested", + "SysprepApplied". + :paramtype windows_os_state: str or ~azure.mgmt.devtestlabs.models.WindowsOsState + """ super(WindowsOsInfo, self).__init__(**kwargs) self.windows_os_state = windows_os_state - - -class WindowsOsInfoFragment(msrest.serialization.Model): - """Information about a Windows OS. - - :param windows_os_state: The state of the Windows OS (i.e. NonSysprepped, SysprepRequested, - SysprepApplied). Possible values include: "NonSysprepped", "SysprepRequested", - "SysprepApplied". - :type windows_os_state: str or ~azure.mgmt.devtestlabs.models.WindowsOsState - """ - - _attribute_map = { - 'windows_os_state': {'key': 'windowsOsState', 'type': 'str'}, - } - - def __init__( - self, - *, - windows_os_state: Optional[Union[str, "WindowsOsState"]] = None, - **kwargs - ): - super(WindowsOsInfoFragment, self).__init__(**kwargs) - self.windows_os_state = windows_os_state diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_arm_templates_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_arm_templates_operations.py index a2fca1cf573c..8ecb8b53e97a 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_arm_templates_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_arm_templates_operations.py @@ -5,23 +5,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/armtemplates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "artifactSourceName": _SERIALIZER.url("artifact_source_name", artifact_source_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/armtemplates/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "artifactSourceName": _SERIALIZER.url("artifact_source_name", artifact_source_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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 ArmTemplatesOperations(object): """ArmTemplatesOperations operations. @@ -45,18 +140,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - artifact_source_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ArmTemplateList"] + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ArmTemplateList"]: """List azure resource manager templates in a given artifact source. :param resource_group_name: The name of the resource group. @@ -84,45 +179,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ArmTemplateList', pipeline_response) + deserialized = self._deserialize("ArmTemplateList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -140,21 +233,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/armtemplates'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - artifact_source_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ArmTemplate" + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.ArmTemplate": """Get azure resource manager template. :param resource_group_name: The name of the resource group. @@ -177,31 +271,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,4 +298,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/armtemplates/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_artifact_sources_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_artifact_sources_operations.py index 3a2397e3e372..4873c2c30fa6 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_artifact_sources_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_artifact_sources_operations.py @@ -5,23 +5,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class ArtifactSourcesOperations(object): """ArtifactSourcesOperations operations. @@ -45,17 +266,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ArtifactSourceList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ArtifactSourceList"]: """List artifact sources in a given lab. :param resource_group_name: The name of the resource group. @@ -81,44 +302,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ArtifactSourceList', pipeline_response) + deserialized = self._deserialize("ArtifactSourceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -136,20 +354,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ArtifactSource" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.ArtifactSource": """Get artifact source. :param resource_group_name: The name of the resource group. @@ -170,30 +389,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -207,17 +415,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - artifact_source, # type: "_models.ArtifactSource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ArtifactSource" + resource_group_name: str, + lab_name: str, + name: str, + artifact_source: "_models.ArtifactSource", + **kwargs: Any + ) -> "_models.ArtifactSource": """Create or replace an existing artifact source. :param resource_group_name: The name of the resource group. @@ -238,33 +448,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(artifact_source, 'ArtifactSource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(artifact_source, 'ArtifactSource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -282,16 +482,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete artifact source. :param resource_group_name: The name of the resource group. @@ -310,28 +512,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -344,15 +536,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - artifact_source, # type: "_models.ArtifactSourceFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.ArtifactSource" + resource_group_name: str, + lab_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.ArtifactSource": """Allows modifying tags of artifact sources. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -361,8 +554,8 @@ def update( :type lab_name: str :param name: The name of the artifact source. :type name: str - :param artifact_source: Properties of an artifact source. - :type artifact_source: ~azure.mgmt.devtestlabs.models.ArtifactSourceFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: ArtifactSource, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.ArtifactSource @@ -373,33 +566,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _artifact_source = _models.ArtifactSourceFragment(tags=tags) + _json = self._serialize.body(_artifact_source, 'ArtifactSourceFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(artifact_source, 'ArtifactSourceFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -413,4 +597,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_artifacts_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_artifacts_operations.py index c7b21cf36eb6..a6fe3c7f8b01 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_artifacts_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_artifacts_operations.py @@ -5,23 +5,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "artifactSourceName": _SERIALIZER.url("artifact_source_name", artifact_source_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "artifactSourceName": _SERIALIZER.url("artifact_source_name", artifact_source_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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_generate_arm_template_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}/generateArmTemplate') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "artifactSourceName": _SERIALIZER.url("artifact_source_name", artifact_source_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class ArtifactsOperations(object): """ArtifactsOperations operations. @@ -45,18 +189,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - artifact_source_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ArtifactList"] + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ArtifactList"]: """List artifacts in a given artifact source. :param resource_group_name: The name of the resource group. @@ -84,45 +228,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ArtifactList', pipeline_response) + deserialized = self._deserialize("ArtifactList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -140,21 +282,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - artifact_source_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Artifact" + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Artifact": """Get artifact. :param resource_group_name: The name of the resource group. @@ -177,31 +320,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,18 +347,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}'} # type: ignore + + @distributed_trace def generate_arm_template( self, - resource_group_name, # type: str - lab_name, # type: str - artifact_source_name, # type: str - name, # type: str - generate_arm_template_request, # type: "_models.GenerateArmTemplateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.ArmTemplateInfo" + resource_group_name: str, + lab_name: str, + artifact_source_name: str, + name: str, + generate_arm_template_request: "_models.GenerateArmTemplateRequest", + **kwargs: Any + ) -> "_models.ArmTemplateInfo": """Generates an ARM template for the given artifact, uploads the required files to a storage account, and validates the generated artifact. @@ -251,34 +385,24 @@ def generate_arm_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.generate_arm_template.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(generate_arm_template_request, 'GenerateArmTemplateRequest') + + request = build_generate_arm_template_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + artifact_source_name=artifact_source_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.generate_arm_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(generate_arm_template_request, 'GenerateArmTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -292,4 +416,6 @@ def generate_arm_template( return cls(pipeline_response, deserialized, {}) return deserialized + generate_arm_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}/generateArmTemplate'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_costs_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_costs_operations.py index 96861c3efbcf..d3183a53a8e8 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_costs_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_costs_operations.py @@ -5,22 +5,112 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class CostsOperations(object): """CostsOperations operations. @@ -44,15 +134,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.LabCost" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.LabCost": """Get cost. :param resource_group_name: The name of the resource group. @@ -73,30 +163,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -110,17 +189,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - lab_cost, # type: "_models.LabCost" - **kwargs # type: Any - ): - # type: (...) -> "_models.LabCost" + resource_group_name: str, + lab_name: str, + name: str, + lab_cost: "_models.LabCost", + **kwargs: Any + ) -> "_models.LabCost": """Create or replace an existing cost. :param resource_group_name: The name of the resource group. @@ -141,33 +222,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(lab_cost, 'LabCost') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_cost, 'LabCost') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,4 +256,6 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_custom_images_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_custom_images_operations.py index af13121d1c49..bef45fb943d2 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_custom_images_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_custom_images_operations.py @@ -5,25 +5,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class CustomImagesOperations(object): """CustomImagesOperations operations. @@ -47,17 +268,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CustomImageList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.CustomImageList"]: """List custom images in a given lab. :param resource_group_name: The name of the resource group. @@ -83,44 +304,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('CustomImageList', pipeline_response) + deserialized = self._deserialize("CustomImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,20 +356,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CustomImage" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.CustomImage": """Get custom image. :param resource_group_name: The name of the resource group. @@ -172,30 +391,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,49 +417,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - custom_image, # type: "_models.CustomImage" - **kwargs # type: Any - ): - # type: (...) -> "_models.CustomImage" + resource_group_name: str, + lab_name: str, + name: str, + custom_image: "_models.CustomImage", + **kwargs: Any + ) -> "_models.CustomImage": cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(custom_image, 'CustomImage') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(custom_image, 'CustomImage') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,17 +468,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - custom_image, # type: "_models.CustomImage" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CustomImage"] + resource_group_name: str, + lab_name: str, + name: str, + custom_image: "_models.CustomImage", + **kwargs: Any + ) -> LROPoller["_models.CustomImage"]: """Create or replace an existing custom image. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -292,15 +493,19 @@ def begin_create_or_update( :type custom_image: ~azure.mgmt.devtestlabs.models.CustomImage :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either CustomImage or the result of cls(response) + :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 CustomImage or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.CustomImage] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomImage"] lro_delay = kwargs.pop( 'polling_interval', @@ -313,28 +518,21 @@ def begin_create_or_update( lab_name=lab_name, name=name, custom_image=custom_image, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CustomImage', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -346,43 +544,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,14 +583,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete custom image. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -413,15 +602,17 @@ def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -436,22 +627,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -463,17 +646,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - custom_image, # type: "_models.CustomImageFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.CustomImage" + resource_group_name: str, + lab_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.CustomImage": """Allows modifying tags of custom images. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -482,8 +666,8 @@ def update( :type lab_name: str :param name: The name of the custom image. :type name: str - :param custom_image: A custom image. - :type custom_image: ~azure.mgmt.devtestlabs.models.CustomImageFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomImage, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.CustomImage @@ -494,33 +678,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _custom_image = _models.CustomImageFragment(tags=tags) + _json = self._serialize.body(_custom_image, 'CustomImageFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(custom_image, 'CustomImageFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -534,4 +709,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_disks_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_disks_operations.py index 044e1fa10005..b5a5b89841e9 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_disks_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_disks_operations.py @@ -5,25 +5,352 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_attach_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/attach') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_detach_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/detach') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class DisksOperations(object): """DisksOperations operations. @@ -47,18 +374,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DiskList"] + resource_group_name: str, + lab_name: str, + user_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DiskList"]: """List disks in a given user profile. :param resource_group_name: The name of the resource group. @@ -86,45 +413,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('DiskList', pipeline_response) + deserialized = self._deserialize("DiskList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,21 +467,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Disk" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Disk": """Get disk. :param resource_group_name: The name of the resource group. @@ -179,31 +505,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,51 +532,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - disk, # type: "_models.Disk" - **kwargs # type: Any - ): - # type: (...) -> "_models.Disk" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + disk: "_models.Disk", + **kwargs: Any + ) -> "_models.Disk": cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(disk, 'Disk') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(disk, 'Disk') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -279,18 +585,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - disk, # type: "_models.Disk" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Disk"] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + disk: "_models.Disk", + **kwargs: Any + ) -> LROPoller["_models.Disk"]: """Create or replace an existing disk. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -305,15 +613,18 @@ def begin_create_or_update( :type disk: ~azure.mgmt.devtestlabs.models.Disk :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Disk or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', @@ -327,29 +638,21 @@ def begin_create_or_update( user_name=user_name, name=name, disk=disk, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Disk', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -361,45 +664,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -412,15 +705,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete disk. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -433,15 +727,17 @@ def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -457,23 +753,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -485,18 +772,19 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - disk, # type: "_models.DiskFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Disk" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Disk": """Allows modifying tags of disks. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -507,8 +795,8 @@ def update( :type user_name: str :param name: The name of the disk. :type name: str - :param disk: A Disk. - :type disk: ~azure.mgmt.devtestlabs.models.DiskFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Disk, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Disk @@ -519,34 +807,25 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _disk = _models.DiskFragment(tags=tags) + _json = self._serialize.body(_disk, 'DiskFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(disk, 'DiskFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -560,53 +839,43 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}'} # type: ignore + def _attach_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - leased_by_lab_vm_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + leased_by_lab_vm_id: Optional[str] = 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', {})) - _attach_disk_properties = _models.AttachDiskProperties(leased_by_lab_vm_id=leased_by_lab_vm_id) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._attach_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _attach_disk_properties = _models.AttachDiskProperties(leased_by_lab_vm_id=leased_by_lab_vm_id) + _json = self._serialize.body(_attach_disk_properties, 'AttachDiskProperties') + + request = build_attach_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._attach_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_attach_disk_properties, 'AttachDiskProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -619,16 +888,17 @@ def _attach_initial( _attach_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/attach'} # type: ignore + + @distributed_trace def begin_attach( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - leased_by_lab_vm_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + leased_by_lab_vm_id: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Attach and create the lease of the disk to the virtual machine. This operation can take a while to complete. @@ -645,15 +915,18 @@ def begin_attach( :type leased_by_lab_vm_id: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -667,26 +940,18 @@ def begin_attach( user_name=user_name, name=name, leased_by_lab_vm_id=leased_by_lab_vm_id, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -698,53 +963,42 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_attach.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/attach'} # type: ignore def _detach_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - leased_by_lab_vm_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + leased_by_lab_vm_id: Optional[str] = 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', {})) - _detach_disk_properties = _models.DetachDiskProperties(leased_by_lab_vm_id=leased_by_lab_vm_id) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._detach_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _detach_disk_properties = _models.DetachDiskProperties(leased_by_lab_vm_id=leased_by_lab_vm_id) + _json = self._serialize.body(_detach_disk_properties, 'DetachDiskProperties') + + request = build_detach_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._detach_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_detach_disk_properties, 'DetachDiskProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -757,16 +1011,17 @@ def _detach_initial( _detach_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/detach'} # type: ignore + + @distributed_trace def begin_detach( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - leased_by_lab_vm_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + leased_by_lab_vm_id: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Detach and break the lease of the disk attached to the virtual machine. This operation can take a while to complete. @@ -782,15 +1037,18 @@ def begin_detach( :type leased_by_lab_vm_id: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -804,26 +1062,18 @@ def begin_detach( user_name=user_name, name=name, leased_by_lab_vm_id=leased_by_lab_vm_id, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -835,4 +1085,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_detach.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/detach'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_environments_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_environments_operations.py index e3da2d9c3b4e..e90b0e1ebc06 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_environments_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_environments_operations.py @@ -5,25 +5,256 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class EnvironmentsOperations(object): """EnvironmentsOperations operations. @@ -47,18 +278,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DtlEnvironmentList"] + resource_group_name: str, + lab_name: str, + user_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DtlEnvironmentList"]: """List environments in a given user profile. :param resource_group_name: The name of the resource group. @@ -86,45 +317,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('DtlEnvironmentList', pipeline_response) + deserialized = self._deserialize("DtlEnvironmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,21 +371,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.DtlEnvironment" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.DtlEnvironment": """Get environment. :param resource_group_name: The name of the resource group. @@ -179,31 +409,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,51 +436,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - dtl_environment, # type: "_models.DtlEnvironment" - **kwargs # type: Any - ): - # type: (...) -> "_models.DtlEnvironment" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + dtl_environment: "_models.DtlEnvironment", + **kwargs: Any + ) -> "_models.DtlEnvironment": cls = kwargs.pop('cls', None) # type: ClsType["_models.DtlEnvironment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(dtl_environment, 'DtlEnvironment') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(dtl_environment, 'DtlEnvironment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -279,18 +489,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - dtl_environment, # type: "_models.DtlEnvironment" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DtlEnvironment"] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + dtl_environment: "_models.DtlEnvironment", + **kwargs: Any + ) -> LROPoller["_models.DtlEnvironment"]: """Create or replace an existing environment. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -305,15 +517,19 @@ def begin_create_or_update( :type dtl_environment: ~azure.mgmt.devtestlabs.models.DtlEnvironment :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DtlEnvironment or the result of cls(response) + :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 DtlEnvironment or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.DtlEnvironment] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DtlEnvironment"] lro_delay = kwargs.pop( 'polling_interval', @@ -327,29 +543,21 @@ def begin_create_or_update( user_name=user_name, name=name, dtl_environment=dtl_environment, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DtlEnvironment', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -361,45 +569,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -412,15 +610,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete environment. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -433,15 +632,17 @@ def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -457,23 +658,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -485,18 +677,19 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - dtl_environment, # type: "_models.DtlEnvironmentFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.DtlEnvironment" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.DtlEnvironment": """Allows modifying tags of environments. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -507,8 +700,8 @@ def update( :type user_name: str :param name: The name of the environment. :type name: str - :param dtl_environment: An environment, which is essentially an ARM template deployment. - :type dtl_environment: ~azure.mgmt.devtestlabs.models.DtlEnvironmentFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: DtlEnvironment, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.DtlEnvironment @@ -519,34 +712,25 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _dtl_environment = _models.DtlEnvironmentFragment(tags=tags) + _json = self._serialize.body(_dtl_environment, 'DtlEnvironmentFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(dtl_environment, 'DtlEnvironmentFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -560,4 +744,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_formulas_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_formulas_operations.py index eefb750c3900..48e9d5afc845 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_formulas_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_formulas_operations.py @@ -5,25 +5,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class FormulasOperations(object): """FormulasOperations operations. @@ -47,17 +268,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.FormulaList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.FormulaList"]: """List formulas in a given lab. :param resource_group_name: The name of the resource group. @@ -83,44 +304,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('FormulaList', pipeline_response) + deserialized = self._deserialize("FormulaList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,20 +356,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Formula" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Formula": """Get formula. :param resource_group_name: The name of the resource group. @@ -172,30 +391,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,49 +417,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - formula, # type: "_models.Formula" - **kwargs # type: Any - ): - # type: (...) -> "_models.Formula" + resource_group_name: str, + lab_name: str, + name: str, + formula: "_models.Formula", + **kwargs: Any + ) -> "_models.Formula": cls = kwargs.pop('cls', None) # type: ClsType["_models.Formula"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(formula, 'Formula') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(formula, 'Formula') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,17 +468,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - formula, # type: "_models.Formula" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Formula"] + resource_group_name: str, + lab_name: str, + name: str, + formula: "_models.Formula", + **kwargs: Any + ) -> LROPoller["_models.Formula"]: """Create or replace an existing formula. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -292,15 +493,18 @@ def begin_create_or_update( :type formula: ~azure.mgmt.devtestlabs.models.Formula :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Formula or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.Formula] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Formula"] lro_delay = kwargs.pop( 'polling_interval', @@ -313,28 +517,21 @@ def begin_create_or_update( lab_name=lab_name, name=name, formula=formula, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Formula', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -346,16 +543,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete formula. :param resource_group_name: The name of the resource group. @@ -374,28 +572,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -408,15 +596,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - formula, # type: "_models.FormulaFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Formula" + resource_group_name: str, + lab_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Formula": """Allows modifying tags of formulas. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -425,8 +614,8 @@ def update( :type lab_name: str :param name: The name of the formula. :type name: str - :param formula: A formula for creating a VM, specifying an image base and other parameters. - :type formula: ~azure.mgmt.devtestlabs.models.FormulaFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Formula, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Formula @@ -437,33 +626,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _formula = _models.FormulaFragment(tags=tags) + _json = self._serialize.body(_formula, 'FormulaFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(formula, 'FormulaFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -477,4 +657,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_gallery_images_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_gallery_images_operations.py index abf735429b1b..917a48f7dba7 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_gallery_images_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_gallery_images_operations.py @@ -5,23 +5,73 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/galleryimages') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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 GalleryImagesOperations(object): """GalleryImagesOperations operations. @@ -45,17 +95,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GalleryImageList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.GalleryImageList"]: """List gallery images in a given lab. :param resource_group_name: The name of the resource group. @@ -81,44 +131,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('GalleryImageList', pipeline_response) + deserialized = self._deserialize("GalleryImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -136,6 +183,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_global_schedules_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_global_schedules_operations.py index 8f8cb436844a..9a2612c2933d 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_global_schedules_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_global_schedules_operations.py @@ -5,25 +5,359 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_by_subscription_request( + subscription_id: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/schedules') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + subscription_id: str, + resource_group_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_execute_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/execute') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_retarget_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/retarget') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class GlobalSchedulesOperations(object): """GlobalSchedulesOperations operations. @@ -47,15 +381,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduleList"] + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ScheduleList"]: """List schedules in a subscription. :param expand: Specify the $expand query. Example: 'properties($select=status)'. @@ -77,42 +411,37 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,21 +459,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/schedules'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduleList"] + resource_group_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ScheduleList"]: """List schedules in a resource group. :param resource_group_name: The name of the resource group. @@ -168,43 +498,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,19 +548,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Schedule": """Get schedule. :param resource_group_name: The name of the resource group. @@ -253,29 +580,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -289,16 +605,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - name, # type: str - schedule, # type: "_models.Schedule" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + name: str, + schedule: "_models.Schedule", + **kwargs: Any + ) -> "_models.Schedule": """Create or replace an existing schedule. :param resource_group_name: The name of the resource group. @@ -317,32 +635,22 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(schedule, 'Schedule') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'Schedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -360,15 +668,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete schedule. :param resource_group_name: The name of the resource group. @@ -385,27 +695,17 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -418,22 +718,23 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - name, # type: str - schedule, # type: "_models.ScheduleFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Schedule": """Allows modifying tags of schedules. All other properties will be ignored. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param name: The name of the schedule. :type name: str - :param schedule: A schedule. - :type schedule: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Schedule @@ -444,32 +745,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _schedule = _models.ScheduleFragment(tags=tags) + _json = self._serialize.body(_schedule, 'ScheduleFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'ScheduleFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -483,41 +775,32 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}'} # type: ignore + def _execute_initial( self, - resource_group_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._execute_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_execute_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self._execute_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -530,13 +813,14 @@ def _execute_initial( _execute_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/execute'} # type: ignore + + @distributed_trace def begin_execute( self, - resource_group_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Execute a schedule. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -545,15 +829,17 @@ def begin_execute( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -567,21 +853,14 @@ def begin_execute( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -593,50 +872,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_execute.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/execute'} # type: ignore def _retarget_initial( self, - resource_group_name, # type: str - name, # type: str - current_resource_id=None, # type: Optional[str] - target_resource_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + name: str, + current_resource_id: Optional[str] = None, + target_resource_id: Optional[str] = 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', {})) - _retarget_schedule_properties = _models.RetargetScheduleProperties(current_resource_id=current_resource_id, target_resource_id=target_resource_id) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._retarget_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _retarget_schedule_properties = _models.RetargetScheduleProperties(current_resource_id=current_resource_id, target_resource_id=target_resource_id) + _json = self._serialize.body(_retarget_schedule_properties, 'RetargetScheduleProperties') + + request = build_retarget_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._retarget_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_retarget_schedule_properties, 'RetargetScheduleProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -649,15 +917,16 @@ def _retarget_initial( _retarget_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/retarget'} # type: ignore + + @distributed_trace def begin_retarget( self, - resource_group_name, # type: str - name, # type: str - current_resource_id=None, # type: Optional[str] - target_resource_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + name: str, + current_resource_id: Optional[str] = None, + target_resource_id: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Updates a schedule's target resource Id. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -672,15 +941,18 @@ def begin_retarget( :type target_resource_id: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -693,24 +965,18 @@ def begin_retarget( name=name, current_resource_id=current_resource_id, target_resource_id=target_resource_id, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -722,4 +988,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_retarget.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/retarget'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_labs_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_labs_operations.py index e164f414ce5f..a1a808790ba4 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_labs_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_labs_operations.py @@ -6,25 +6,526 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_by_subscription_request( + subscription_id: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/labs') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_claim_any_vm_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/claimAnyVm') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_environment_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_export_resource_usage_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/exportResourceUsage') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_generate_upload_uri_request( + subscription_id: str, + resource_group_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/generateUploadUri') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_import_virtual_machine_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/importVirtualMachine') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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_vhds_request( + subscription_id: str, + resource_group_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/listVhds') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class LabsOperations(object): """LabsOperations operations. @@ -48,15 +549,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LabList"] + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.LabList"]: """List labs in a subscription. :param expand: Specify the $expand query. Example: 'properties($select=defaultStorageAccount)'. @@ -78,42 +579,37 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('LabList', pipeline_response) + deserialized = self._deserialize("LabList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,21 +627,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/labs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LabList"] + resource_group_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.LabList"]: """List labs in a resource group. :param resource_group_name: The name of the resource group. @@ -169,43 +666,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('LabList', pipeline_response) + deserialized = self._deserialize("LabList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -223,19 +716,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Lab" + resource_group_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Lab": """Get lab. :param resource_group_name: The name of the resource group. @@ -254,29 +748,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -290,47 +773,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - name, # type: str - lab, # type: "_models.Lab" - **kwargs # type: Any - ): - # type: (...) -> "_models.Lab" + resource_group_name: str, + name: str, + lab: "_models.Lab", + **kwargs: Any + ) -> "_models.Lab": cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(lab, 'Lab') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab, 'Lab') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -348,16 +822,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - name, # type: str - lab, # type: "_models.Lab" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Lab"] + resource_group_name: str, + name: str, + lab: "_models.Lab", + **kwargs: Any + ) -> LROPoller["_models.Lab"]: """Create or replace an existing lab. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -368,15 +844,18 @@ def begin_create_or_update( :type lab: ~azure.mgmt.devtestlabs.models.Lab :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Lab or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.Lab] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] lro_delay = kwargs.pop( 'polling_interval', @@ -388,27 +867,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, name=name, lab=lab, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Lab', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -420,41 +893,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,13 +930,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete lab. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -482,15 +946,17 @@ def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -504,21 +970,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -530,24 +989,25 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - name, # type: str - lab, # type: "_models.LabFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Lab" + resource_group_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Lab": """Allows modifying tags of labs. All other properties will be ignored. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param name: The name of the lab. :type name: str - :param lab: A lab. - :type lab: ~azure.mgmt.devtestlabs.models.LabFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Lab, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Lab @@ -558,32 +1018,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _lab = _models.LabFragment(tags=tags) + _json = self._serialize.body(_lab, 'LabFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab, 'LabFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -597,41 +1048,32 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}'} # type: ignore + def _claim_any_vm_initial( self, - resource_group_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._claim_any_vm_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_claim_any_vm_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self._claim_any_vm_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -644,13 +1086,14 @@ def _claim_any_vm_initial( _claim_any_vm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/claimAnyVm'} # type: ignore + + @distributed_trace def begin_claim_any_vm( self, - resource_group_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Claim a random claimable virtual machine in the lab. This operation can take a while to complete. @@ -660,15 +1103,17 @@ def begin_claim_any_vm( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -682,21 +1127,14 @@ def begin_claim_any_vm( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -708,47 +1146,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_claim_any_vm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/claimAnyVm'} # type: ignore def _create_environment_initial( self, - resource_group_name, # type: str - name, # type: str - lab_virtual_machine_creation_parameter, # type: "_models.LabVirtualMachineCreationParameter" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + name: str, + lab_virtual_machine_creation_parameter: "_models.LabVirtualMachineCreationParameter", + **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 = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_environment_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(lab_virtual_machine_creation_parameter, 'LabVirtualMachineCreationParameter') + + request = build_create_environment_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_environment_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_virtual_machine_creation_parameter, 'LabVirtualMachineCreationParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -761,14 +1189,15 @@ def _create_environment_initial( _create_environment_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment'} # type: ignore + + @distributed_trace def begin_create_environment( self, - resource_group_name, # type: str - name, # type: str - lab_virtual_machine_creation_parameter, # type: "_models.LabVirtualMachineCreationParameter" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + name: str, + lab_virtual_machine_creation_parameter: "_models.LabVirtualMachineCreationParameter", + **kwargs: Any + ) -> LROPoller[None]: """Create virtual machines in a lab. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -776,18 +1205,22 @@ def begin_create_environment( :param name: The name of the lab. :type name: str :param lab_virtual_machine_creation_parameter: Properties for creating a virtual machine. - :type lab_virtual_machine_creation_parameter: ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameter + :type lab_virtual_machine_creation_parameter: + ~azure.mgmt.devtestlabs.models.LabVirtualMachineCreationParameter :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -799,24 +1232,18 @@ def begin_create_environment( resource_group_name=resource_group_name, name=name, lab_virtual_machine_creation_parameter=lab_virtual_machine_creation_parameter, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -828,50 +1255,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_environment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment'} # type: ignore def _export_resource_usage_initial( self, - resource_group_name, # type: str - name, # type: str - blob_storage_absolute_sas_uri=None, # type: Optional[str] - usage_start_date=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + name: str, + blob_storage_absolute_sas_uri: Optional[str] = None, + usage_start_date: Optional[datetime.datetime] = 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', {})) - _export_resource_usage_parameters = _models.ExportResourceUsageParameters(blob_storage_absolute_sas_uri=blob_storage_absolute_sas_uri, usage_start_date=usage_start_date) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_resource_usage_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _export_resource_usage_parameters = _models.ExportResourceUsageParameters(blob_storage_absolute_sas_uri=blob_storage_absolute_sas_uri, usage_start_date=usage_start_date) + _json = self._serialize.body(_export_resource_usage_parameters, 'ExportResourceUsageParameters') + + request = build_export_resource_usage_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._export_resource_usage_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_export_resource_usage_parameters, 'ExportResourceUsageParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -884,15 +1300,16 @@ def _export_resource_usage_initial( _export_resource_usage_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/exportResourceUsage'} # type: ignore + + @distributed_trace def begin_export_resource_usage( self, - resource_group_name, # type: str - name, # type: str - blob_storage_absolute_sas_uri=None, # type: Optional[str] - usage_start_date=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + name: str, + blob_storage_absolute_sas_uri: Optional[str] = None, + usage_start_date: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> LROPoller[None]: """Exports the lab resource usage into a storage account This operation can take a while to complete. @@ -908,15 +1325,18 @@ def begin_export_resource_usage( :type usage_start_date: ~datetime.datetime :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -929,24 +1349,18 @@ def begin_export_resource_usage( name=name, blob_storage_absolute_sas_uri=blob_storage_absolute_sas_uri, usage_start_date=usage_start_date, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -958,16 +1372,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_resource_usage.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/exportResourceUsage'} # type: ignore + @distributed_trace def generate_upload_uri( self, - resource_group_name, # type: str - name, # type: str - blob_name=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.GenerateUploadUriResponse" + resource_group_name: str, + name: str, + blob_name: Optional[str] = None, + **kwargs: Any + ) -> "_models.GenerateUploadUriResponse": """Generate a URI for uploading custom disk images to a Lab. :param resource_group_name: The name of the resource group. @@ -987,33 +1402,22 @@ def generate_upload_uri( } error_map.update(kwargs.pop('error_map', {})) - _generate_upload_uri_parameter = _models.GenerateUploadUriParameter(blob_name=blob_name) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.generate_upload_uri.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _generate_upload_uri_parameter = _models.GenerateUploadUriParameter(blob_name=blob_name) + _json = self._serialize.body(_generate_upload_uri_parameter, 'GenerateUploadUriParameter') + + request = build_generate_upload_uri_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.generate_upload_uri.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_generate_upload_uri_parameter, 'GenerateUploadUriParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1027,50 +1431,40 @@ def generate_upload_uri( return cls(pipeline_response, deserialized, {}) return deserialized + generate_upload_uri.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/generateUploadUri'} # type: ignore + def _import_virtual_machine_initial( self, - resource_group_name, # type: str - name, # type: str - source_virtual_machine_resource_id=None, # type: Optional[str] - destination_virtual_machine_name=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + name: str, + source_virtual_machine_resource_id: Optional[str] = None, + destination_virtual_machine_name: Optional[str] = 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', {})) - _import_lab_virtual_machine_request = _models.ImportLabVirtualMachineRequest(source_virtual_machine_resource_id=source_virtual_machine_resource_id, destination_virtual_machine_name=destination_virtual_machine_name) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._import_virtual_machine_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _import_lab_virtual_machine_request = _models.ImportLabVirtualMachineRequest(source_virtual_machine_resource_id=source_virtual_machine_resource_id, destination_virtual_machine_name=destination_virtual_machine_name) + _json = self._serialize.body(_import_lab_virtual_machine_request, 'ImportLabVirtualMachineRequest') + + request = build_import_virtual_machine_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._import_virtual_machine_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_import_lab_virtual_machine_request, 'ImportLabVirtualMachineRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1083,15 +1477,16 @@ def _import_virtual_machine_initial( _import_virtual_machine_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/importVirtualMachine'} # type: ignore + + @distributed_trace def begin_import_virtual_machine( self, - resource_group_name, # type: str - name, # type: str - source_virtual_machine_resource_id=None, # type: Optional[str] - destination_virtual_machine_name=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + name: str, + source_virtual_machine_resource_id: Optional[str] = None, + destination_virtual_machine_name: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Import a virtual machine into a different lab. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -1106,15 +1501,18 @@ def begin_import_virtual_machine( :type destination_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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1127,24 +1525,18 @@ def begin_import_virtual_machine( name=name, source_virtual_machine_resource_id=source_virtual_machine_resource_id, destination_virtual_machine_name=destination_virtual_machine_name, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1156,15 +1548,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_import_virtual_machine.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/importVirtualMachine'} # type: ignore + @distributed_trace def list_vhds( self, - resource_group_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LabVhdList"] + resource_group_name: str, + name: str, + **kwargs: Any + ) -> Iterable["_models.LabVhdList"]: """List disk images available for custom image creation. :param resource_group_name: The name of the resource group. @@ -1181,36 +1574,33 @@ def list_vhds( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_vhds.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_vhds_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=self.list_vhds.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_vhds_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LabVhdList', pipeline_response) + deserialized = self._deserialize("LabVhdList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1228,6 +1618,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_notification_channels_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_notification_channels_operations.py index 16808e656def..137b1700df1f 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_notification_channels_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_notification_channels_operations.py @@ -5,23 +5,290 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_notify_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}/notify') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class NotificationChannelsOperations(object): """NotificationChannelsOperations operations. @@ -45,17 +312,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NotificationChannelList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.NotificationChannelList"]: """List notification channels in a given lab. :param resource_group_name: The name of the resource group. @@ -72,7 +339,8 @@ def list( '$orderby=name desc'. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NotificationChannelList or the result of cls(response) + :return: An iterator like instance of either NotificationChannelList or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.devtestlabs.models.NotificationChannelList] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -81,44 +349,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('NotificationChannelList', pipeline_response) + deserialized = self._deserialize("NotificationChannelList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -136,20 +401,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.NotificationChannel" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.NotificationChannel": """Get notification channel. :param resource_group_name: The name of the resource group. @@ -170,30 +436,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -207,17 +462,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - notification_channel, # type: "_models.NotificationChannel" - **kwargs # type: Any - ): - # type: (...) -> "_models.NotificationChannel" + resource_group_name: str, + lab_name: str, + name: str, + notification_channel: "_models.NotificationChannel", + **kwargs: Any + ) -> "_models.NotificationChannel": """Create or replace an existing notification channel. :param resource_group_name: The name of the resource group. @@ -238,33 +495,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(notification_channel, 'NotificationChannel') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(notification_channel, 'NotificationChannel') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -282,16 +529,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete notification channel. :param resource_group_name: The name of the resource group. @@ -310,28 +559,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -344,15 +583,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - notification_channel, # type: "_models.NotificationChannelFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.NotificationChannel" + resource_group_name: str, + lab_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.NotificationChannel": """Allows modifying tags of notification channels. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -361,8 +601,8 @@ def update( :type lab_name: str :param name: The name of the notification channel. :type name: str - :param notification_channel: A notification. - :type notification_channel: ~azure.mgmt.devtestlabs.models.NotificationChannelFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: NotificationChannel, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.NotificationChannel @@ -373,33 +613,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _notification_channel = _models.NotificationChannelFragment(tags=tags) + _json = self._serialize.body(_notification_channel, 'NotificationChannelFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(notification_channel, 'NotificationChannelFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -413,18 +644,20 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}'} # type: ignore + + @distributed_trace def notify( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - event_name=None, # type: Optional[Union[str, "_models.NotificationChannelEventType"]] - json_payload=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + event_name: Optional[Union[str, "_models.NotificationChannelEventType"]] = None, + json_payload: Optional[str] = None, + **kwargs: Any + ) -> None: """Send notification to provided channel. :param resource_group_name: The name of the resource group. @@ -448,34 +681,23 @@ def notify( } error_map.update(kwargs.pop('error_map', {})) - _notify_parameters = _models.NotifyParameters(event_name=event_name, json_payload=json_payload) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.notify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _notify_parameters = _models.NotifyParameters(event_name=event_name, json_payload=json_payload) + _json = self._serialize.body(_notify_parameters, 'NotifyParameters') + + request = build_notify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.notify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_notify_parameters, 'NotifyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -487,3 +709,4 @@ def notify( return cls(pipeline_response, None, {}) notify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}/notify'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_operations.py index 92225c143fa2..f343a8631f99 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_operations.py @@ -5,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + location_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/locations/{locationName}/operations/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "name": _SERIALIZER.url("name", 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 Operations(object): """Operations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - location_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationResult" + location_name: str, + name: str, + **kwargs: Any + ) -> "_models.OperationResult": """Get operation. :param location_name: The name of the location. @@ -67,38 +104,34 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + location_name=location_name, + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + 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) - deserialized = self._deserialize('OperationResult', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize('OperationResult', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('OperationResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/locations/{locationName}/operations/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_policies_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_policies_operations.py index 98a56b3a700b..041b8faa60d5 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_policies_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_policies_operations.py @@ -5,23 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + policy_set_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "policySetName": _SERIALIZER.url("policy_set_name", policy_set_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + policy_set_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "policySetName": _SERIALIZER.url("policy_set_name", policy_set_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + policy_set_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "policySetName": _SERIALIZER.url("policy_set_name", policy_set_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + policy_set_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "policySetName": _SERIALIZER.url("policy_set_name", policy_set_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + policy_set_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "policySetName": _SERIALIZER.url("policy_set_name", policy_set_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class PoliciesOperations(object): """PoliciesOperations operations. @@ -45,18 +276,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - policy_set_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PolicyList"] + resource_group_name: str, + lab_name: str, + policy_set_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PolicyList"]: """List policies in a given policy set. :param resource_group_name: The name of the resource group. @@ -84,45 +315,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('PolicyList', pipeline_response) + deserialized = self._deserialize("PolicyList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -140,21 +369,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - policy_set_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Policy" + resource_group_name: str, + lab_name: str, + policy_set_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Policy": """Get policy. :param resource_group_name: The name of the resource group. @@ -177,31 +407,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,18 +434,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - policy_set_name, # type: str - name, # type: str - policy, # type: "_models.Policy" - **kwargs # type: Any - ): - # type: (...) -> "_models.Policy" + resource_group_name: str, + lab_name: str, + policy_set_name: str, + name: str, + policy: "_models.Policy", + **kwargs: Any + ) -> "_models.Policy": """Create or replace an existing policy. :param resource_group_name: The name of the resource group. @@ -249,34 +470,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(policy, 'Policy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(policy, 'Policy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -294,17 +505,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - policy_set_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + policy_set_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete policy. :param resource_group_name: The name of the resource group. @@ -325,29 +538,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -360,16 +563,17 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - policy_set_name, # type: str - name, # type: str - policy, # type: "_models.PolicyFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Policy" + resource_group_name: str, + lab_name: str, + policy_set_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Policy": """Allows modifying tags of policies. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -380,8 +584,8 @@ def update( :type policy_set_name: str :param name: The name of the policy. :type name: str - :param policy: A Policy. - :type policy: ~azure.mgmt.devtestlabs.models.PolicyFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Policy, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Policy @@ -392,34 +596,25 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'policySetName': self._serialize.url("policy_set_name", policy_set_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _policy = _models.PolicyFragment(tags=tags) + _json = self._serialize.body(_policy, 'PolicyFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + policy_set_name=policy_set_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(policy, 'PolicyFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -433,4 +628,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_policy_sets_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_policy_sets_operations.py index f0356e649e37..440cdfec7a3a 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_policy_sets_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_policy_sets_operations.py @@ -5,22 +5,71 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_evaluate_policies_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{name}/evaluatePolicies') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class PolicySetsOperations(object): """PolicySetsOperations operations. @@ -44,15 +93,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def evaluate_policies( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - policies=None, # type: Optional[List["_models.EvaluatePoliciesProperties"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.EvaluatePoliciesResponse" + resource_group_name: str, + lab_name: str, + name: str, + policies: Optional[List["_models.EvaluatePoliciesProperties"]] = None, + **kwargs: Any + ) -> "_models.EvaluatePoliciesResponse": """Evaluates lab policy. :param resource_group_name: The name of the resource group. @@ -74,34 +123,23 @@ def evaluate_policies( } error_map.update(kwargs.pop('error_map', {})) - _evaluate_policies_request = _models.EvaluatePoliciesRequest(policies=policies) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.evaluate_policies.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _evaluate_policies_request = _models.EvaluatePoliciesRequest(policies=policies) + _json = self._serialize.body(_evaluate_policies_request, 'EvaluatePoliciesRequest') + + request = build_evaluate_policies_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.evaluate_policies.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_evaluate_policies_request, 'EvaluatePoliciesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -115,4 +153,6 @@ def evaluate_policies( return cls(pipeline_response, deserialized, {}) return deserialized + evaluate_policies.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{name}/evaluatePolicies'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_provider_operations_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_provider_operations_operations.py index db59d4590c0d..50fb803ec126 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_provider_operations_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_provider_operations_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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 = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.DevTestLab/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 ProviderOperationsOperations(object): """ProviderOperationsOperations operations. @@ -45,15 +72,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProviderOperationResult"] + **kwargs: Any + ) -> Iterable["_models.ProviderOperationResult"]: """Result of the request to list REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationResult or the result of cls(response) + :return: An iterator like instance of either ProviderOperationResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.devtestlabs.models.ProviderOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + 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('ProviderOperationResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +128,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_schedules_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_schedules_operations.py index 04e61b479eb6..9e79b7d1ecfa 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_schedules_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_schedules_operations.py @@ -5,25 +5,320 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_execute_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/execute') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_list_applicable_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/listApplicable') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class SchedulesOperations(object): """SchedulesOperations operations. @@ -47,17 +342,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduleList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ScheduleList"]: """List schedules in a given lab. :param resource_group_name: The name of the resource group. @@ -83,44 +378,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,20 +430,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Schedule": """Get schedule. :param resource_group_name: The name of the resource group. @@ -172,30 +465,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,17 +491,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - schedule, # type: "_models.Schedule" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + name: str, + schedule: "_models.Schedule", + **kwargs: Any + ) -> "_models.Schedule": """Create or replace an existing schedule. :param resource_group_name: The name of the resource group. @@ -240,33 +524,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(schedule, 'Schedule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'Schedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -284,16 +558,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete schedule. :param resource_group_name: The name of the resource group. @@ -312,28 +588,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -346,15 +612,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - schedule, # type: "_models.ScheduleFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Schedule": """Allows modifying tags of schedules. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -363,8 +630,8 @@ def update( :type lab_name: str :param name: The name of the schedule. :type name: str - :param schedule: A schedule. - :type schedule: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Schedule @@ -375,33 +642,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _schedule = _models.ScheduleFragment(tags=tags) + _json = self._serialize.body(_schedule, 'ScheduleFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'ScheduleFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -415,43 +673,34 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}'} # type: ignore + def _execute_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._execute_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_execute_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._execute_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -464,14 +713,15 @@ def _execute_initial( _execute_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/execute'} # type: ignore + + @distributed_trace def begin_execute( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Execute a schedule. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -482,15 +732,17 @@ def begin_execute( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -505,22 +757,14 @@ def begin_execute( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -532,16 +776,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_execute.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/execute'} # type: ignore + @distributed_trace def list_applicable( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduleList"] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> Iterable["_models.ScheduleList"]: """Lists all applicable schedules. :param resource_group_name: The name of the resource group. @@ -560,37 +805,35 @@ def list_applicable( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_applicable.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_applicable_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.list_applicable.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_applicable_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -608,6 +851,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_secrets_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_secrets_operations.py index c5dac71c3edd..e6f524e0ff9a 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_secrets_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_secrets_operations.py @@ -5,25 +5,256 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class SecretsOperations(object): """SecretsOperations operations. @@ -47,18 +278,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecretList"] + resource_group_name: str, + lab_name: str, + user_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SecretList"]: """List secrets in a given user profile. :param resource_group_name: The name of the resource group. @@ -86,45 +317,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('SecretList', pipeline_response) + deserialized = self._deserialize("SecretList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,21 +371,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Secret" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Secret": """Get secret. :param resource_group_name: The name of the resource group. @@ -179,31 +409,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,51 +436,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - secret, # type: "_models.Secret" - **kwargs # type: Any - ): - # type: (...) -> "_models.Secret" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + secret: "_models.Secret", + **kwargs: Any + ) -> "_models.Secret": cls = kwargs.pop('cls', None) # type: ClsType["_models.Secret"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(secret, 'Secret') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(secret, 'Secret') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -279,18 +489,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - secret, # type: "_models.Secret" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Secret"] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + secret: "_models.Secret", + **kwargs: Any + ) -> LROPoller["_models.Secret"]: """Create or replace an existing secret. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -305,15 +517,18 @@ def begin_create_or_update( :type secret: ~azure.mgmt.devtestlabs.models.Secret :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Secret or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.Secret] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Secret"] lro_delay = kwargs.pop( 'polling_interval', @@ -327,29 +542,21 @@ def begin_create_or_update( user_name=user_name, name=name, secret=secret, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Secret', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -361,17 +568,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete secret. :param resource_group_name: The name of the resource group. @@ -392,29 +600,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -427,17 +625,17 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - tags=None, # type: Optional[Dict[str, str]] - value=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Secret" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Secret": """Allows modifying tags of secrets. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -450,8 +648,6 @@ def update( :type name: str :param tags: The tags of the resource. :type tags: dict[str, str] - :param value: The value of the secret for secret creation. - :type value: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Secret, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Secret @@ -463,35 +659,24 @@ def update( } error_map.update(kwargs.pop('error_map', {})) - _secret = _models.SecretFragment(tags=tags, value=value) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _secret = _models.SecretFragment(tags=tags) + _json = self._serialize.body(_secret, 'SecretFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_secret, 'SecretFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -505,4 +690,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_fabric_schedules_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_fabric_schedules_operations.py index fcedae3b5264..d2cc5e55a05b 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_fabric_schedules_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_fabric_schedules_operations.py @@ -5,25 +5,307 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "serviceFabricName": _SERIALIZER.url("service_fabric_name", service_fabric_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "serviceFabricName": _SERIALIZER.url("service_fabric_name", service_fabric_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "serviceFabricName": _SERIALIZER.url("service_fabric_name", service_fabric_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "serviceFabricName": _SERIALIZER.url("service_fabric_name", service_fabric_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "serviceFabricName": _SERIALIZER.url("service_fabric_name", service_fabric_name, 'str'), + "name": _SERIALIZER.url("name", 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_execute_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}/execute') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "serviceFabricName": _SERIALIZER.url("service_fabric_name", service_fabric_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class ServiceFabricSchedulesOperations(object): """ServiceFabricSchedulesOperations operations. @@ -47,19 +329,19 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - service_fabric_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduleList"] + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ScheduleList"]: """List schedules in a given service fabric. :param resource_group_name: The name of the resource group. @@ -89,46 +371,45 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -146,22 +427,23 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - service_fabric_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Schedule": """Get schedule. :param resource_group_name: The name of the resource group. @@ -186,32 +468,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -225,19 +496,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - service_fabric_name, # type: str - name, # type: str - schedule, # type: "_models.Schedule" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + schedule: "_models.Schedule", + **kwargs: Any + ) -> "_models.Schedule": """Create or replace an existing schedule. :param resource_group_name: The name of the resource group. @@ -262,35 +535,25 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(schedule, 'Schedule') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'Schedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,18 +571,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - service_fabric_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete schedule. :param resource_group_name: The name of the resource group. @@ -342,30 +607,20 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -378,17 +633,18 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - service_fabric_name, # type: str - name, # type: str - schedule, # type: "_models.ScheduleFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Schedule": """Allows modifying tags of schedules. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -401,8 +657,8 @@ def update( :type service_fabric_name: str :param name: The name of the schedule. :type name: str - :param schedule: A schedule. - :type schedule: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Schedule @@ -413,35 +669,26 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _schedule = _models.ScheduleFragment(tags=tags) + _json = self._serialize.body(_schedule, 'ScheduleFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'ScheduleFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -455,47 +702,38 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}'} # type: ignore + def _execute_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - service_fabric_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._execute_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_execute_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + service_fabric_name=service_fabric_name, + name=name, + template_url=self._execute_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -508,16 +746,17 @@ def _execute_initial( _execute_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}/execute'} # type: ignore + + @distributed_trace def begin_execute( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - service_fabric_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + user_name: str, + service_fabric_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Execute a schedule. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -532,15 +771,17 @@ def begin_execute( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -557,24 +798,14 @@ def begin_execute( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'serviceFabricName': self._serialize.url("service_fabric_name", service_fabric_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -586,4 +817,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_execute.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{serviceFabricName}/schedules/{name}/execute'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_fabrics_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_fabrics_operations.py index b9f877ec224e..e1b0f4d99224 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_fabrics_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_fabrics_operations.py @@ -5,25 +5,373 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_applicable_schedules_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/listApplicableSchedules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_start_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/start') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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_stop_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/stop') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "userName": _SERIALIZER.url("user_name", user_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class ServiceFabricsOperations(object): """ServiceFabricsOperations operations. @@ -47,18 +395,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServiceFabricList"] + resource_group_name: str, + lab_name: str, + user_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ServiceFabricList"]: """List service fabrics in a given user profile. :param resource_group_name: The name of the resource group. @@ -86,45 +434,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ServiceFabricList', pipeline_response) + deserialized = self._deserialize("ServiceFabricList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,21 +488,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceFabric" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.ServiceFabric": """Get service fabric. :param resource_group_name: The name of the resource group. @@ -179,31 +526,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,51 +553,42 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - service_fabric, # type: "_models.ServiceFabric" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceFabric" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + service_fabric: "_models.ServiceFabric", + **kwargs: Any + ) -> "_models.ServiceFabric": cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceFabric"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(service_fabric, 'ServiceFabric') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_fabric, 'ServiceFabric') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -279,18 +606,20 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - service_fabric, # type: "_models.ServiceFabric" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServiceFabric"] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + service_fabric: "_models.ServiceFabric", + **kwargs: Any + ) -> LROPoller["_models.ServiceFabric"]: """Create or replace an existing service fabric. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -305,15 +634,19 @@ def begin_create_or_update( :type service_fabric: ~azure.mgmt.devtestlabs.models.ServiceFabric :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ServiceFabric or the result of cls(response) + :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 ServiceFabric or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.ServiceFabric] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceFabric"] lro_delay = kwargs.pop( 'polling_interval', @@ -327,29 +660,21 @@ def begin_create_or_update( user_name=user_name, name=name, service_fabric=service_fabric, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ServiceFabric', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -361,45 +686,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -412,15 +727,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete service fabric. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -433,15 +749,17 @@ def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -457,23 +775,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -485,18 +794,19 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - service_fabric, # type: "_models.ServiceFabricFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceFabric" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.ServiceFabric": """Allows modifying tags of service fabrics. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -507,8 +817,8 @@ def update( :type user_name: str :param name: The name of the service fabric. :type name: str - :param service_fabric: A Service Fabric. - :type service_fabric: ~azure.mgmt.devtestlabs.models.ServiceFabricFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceFabric, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.ServiceFabric @@ -519,34 +829,25 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _service_fabric = _models.ServiceFabricFragment(tags=tags) + _json = self._serialize.body(_service_fabric, 'ServiceFabricFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_fabric, 'ServiceFabricFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -560,17 +861,19 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}'} # type: ignore + + @distributed_trace def list_applicable_schedules( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicableSchedule" + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any + ) -> "_models.ApplicableSchedule": """Lists the applicable start/stop schedules, if any. :param resource_group_name: The name of the resource group. @@ -591,29 +894,19 @@ def list_applicable_schedules( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.list_applicable_schedules.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_applicable_schedules_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self.list_applicable_schedules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -627,45 +920,36 @@ def list_applicable_schedules( return cls(pipeline_response, deserialized, {}) return deserialized + list_applicable_schedules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/listApplicableSchedules'} # type: ignore + def _start_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -678,15 +962,16 @@ def _start_initial( _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/start'} # type: ignore + + @distributed_trace def begin_start( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Start a service fabric. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -699,15 +984,17 @@ def begin_start( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -723,23 +1010,14 @@ def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -751,45 +1029,35 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/start'} # type: ignore def _stop_initial( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + name=name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -802,15 +1070,16 @@ def _stop_initial( _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/stop'} # type: ignore + + @distributed_trace def begin_stop( self, - resource_group_name, # type: str - lab_name, # type: str - user_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + user_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Stop a service fabric This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -823,15 +1092,17 @@ def begin_stop( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -847,23 +1118,14 @@ def begin_stop( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -875,4 +1137,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/stop'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_runners_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_runners_operations.py index ae6b6537e611..f904ae979bd5 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_runners_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_service_runners_operations.py @@ -5,22 +5,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class ServiceRunnersOperations(object): """ServiceRunnersOperations operations. @@ -44,14 +167,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceRunner" + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> "_models.ServiceRunner": """Get service runner. :param resource_group_name: The name of the resource group. @@ -70,28 +193,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,17 +218,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - service_runner, # type: "_models.ServiceRunner" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceRunner" + resource_group_name: str, + lab_name: str, + name: str, + service_runner: "_models.ServiceRunner", + **kwargs: Any + ) -> "_models.ServiceRunner": """Create or replace an existing service runner. :param resource_group_name: The name of the resource group. @@ -136,33 +251,23 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(service_runner, 'ServiceRunner') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_runner, 'ServiceRunner') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -180,16 +285,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete service runner. :param resource_group_name: The name of the resource group. @@ -208,28 +315,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -241,3 +338,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_users_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_users_operations.py index 25168f7c139c..3d18e4518e21 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_users_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_users_operations.py @@ -5,25 +5,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class UsersOperations(object): """UsersOperations operations. @@ -47,17 +268,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.UserList"]: """List user profiles in a given lab. :param resource_group_name: The name of the resource group. @@ -83,44 +304,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,20 +356,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.User": """Get user profile. :param resource_group_name: The name of the resource group. @@ -172,30 +391,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,49 +417,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + resource_group_name: str, + lab_name: str, + name: str, + user: "_models.User", + **kwargs: Any + ) -> "_models.User": cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(user, 'User') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,17 +468,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + resource_group_name: str, + lab_name: str, + name: str, + user: "_models.User", + **kwargs: Any + ) -> LROPoller["_models.User"]: """Create or replace an existing user profile. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -292,15 +493,18 @@ def begin_create_or_update( :type user: ~azure.mgmt.devtestlabs.models.User :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.User] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] lro_delay = kwargs.pop( 'polling_interval', @@ -313,28 +517,21 @@ def begin_create_or_update( lab_name=lab_name, name=name, user=user, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('User', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -346,43 +543,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,14 +582,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete user profile. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -413,15 +601,17 @@ def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -436,22 +626,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -463,17 +645,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - user, # type: "_models.UserFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + resource_group_name: str, + lab_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.User": """Allows modifying tags of user profiles. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -482,8 +665,8 @@ def update( :type lab_name: str :param name: The name of the user profile. :type name: str - :param user: Profile of a lab user. - :type user: ~azure.mgmt.devtestlabs.models.UserFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: User, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.User @@ -494,33 +677,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _user = _models.UserFragment(tags=tags) + _json = self._serialize.body(_user, 'UserFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'UserFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -534,4 +708,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}'} # type: ignore + diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_machine_schedules_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_machine_schedules_operations.py index aebc3a28c782..5f6a460c560e 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_machine_schedules_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_machine_schedules_operations.py @@ -5,25 +5,295 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "name": _SERIALIZER.url("name", 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( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "name": _SERIALIZER.url("name", 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_execute_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}/execute') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class VirtualMachineSchedulesOperations(object): """VirtualMachineSchedulesOperations operations. @@ -47,18 +317,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - virtual_machine_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduleList"] + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ScheduleList"]: """List schedules in a given virtual machine. :param resource_group_name: The name of the resource group. @@ -86,45 +356,43 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('ScheduleList', pipeline_response) + deserialized = self._deserialize("ScheduleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,21 +410,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - virtual_machine_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Schedule": """Get schedule. :param resource_group_name: The name of the resource group. @@ -179,31 +448,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,18 +475,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - virtual_machine_name, # type: str - name, # type: str - schedule, # type: "_models.Schedule" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + schedule: "_models.Schedule", + **kwargs: Any + ) -> "_models.Schedule": """Create or replace an existing schedule. :param resource_group_name: The name of the resource group. @@ -251,34 +511,24 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(schedule, 'Schedule') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'Schedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -296,17 +546,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - lab_name, # type: str - virtual_machine_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any + ) -> None: """Delete schedule. :param resource_group_name: The name of the resource group. @@ -327,29 +579,19 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -362,16 +604,17 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - virtual_machine_name, # type: str - name, # type: str - schedule, # type: "_models.ScheduleFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.Schedule": """Allows modifying tags of schedules. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -382,8 +625,8 @@ def update( :type virtual_machine_name: str :param name: The name of the schedule. :type name: str - :param schedule: A schedule. - :type schedule: ~azure.mgmt.devtestlabs.models.ScheduleFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.Schedule @@ -394,34 +637,25 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _schedule = _models.ScheduleFragment(tags=tags) + _json = self._serialize.body(_schedule, 'ScheduleFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(schedule, 'ScheduleFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -435,45 +669,36 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}'} # type: ignore + def _execute_initial( self, - resource_group_name, # type: str - lab_name, # type: str - virtual_machine_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._execute_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_execute_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + name=name, + template_url=self._execute_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -486,15 +711,16 @@ def _execute_initial( _execute_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}/execute'} # type: ignore + + @distributed_trace def begin_execute( self, - resource_group_name, # type: str - lab_name, # type: str - virtual_machine_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Execute a schedule. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -507,15 +733,17 @@ def begin_execute( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -531,23 +759,14 @@ def begin_execute( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -559,4 +778,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_execute.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}/execute'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_machines_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_machines_operations.py index 626ea2158dfe..2fca11160a38 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_machines_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_machines_operations.py @@ -5,25 +5,763 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_add_data_disk_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_apply_artifacts_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_claim_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_detach_data_disk_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_get_rdp_file_contents_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/getRdpFileContents') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_list_applicable_schedules_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/listApplicableSchedules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_redeploy_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/redeploy') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_resize_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/resize') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_restart_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/restart') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_start_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_stop_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_transfer_disks_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/transferDisks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_un_claim_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/unClaim') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class VirtualMachinesOperations(object): """VirtualMachinesOperations operations. @@ -47,17 +785,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LabVirtualMachineList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.LabVirtualMachineList"]: """List virtual machines in a given lab. :param resource_group_name: The name of the resource group. @@ -75,7 +813,8 @@ def list( '$orderby=name desc'. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LabVirtualMachineList or the result of cls(response) + :return: An iterator like instance of either LabVirtualMachineList or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.devtestlabs.models.LabVirtualMachineList] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -84,44 +823,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('LabVirtualMachineList', pipeline_response) + deserialized = self._deserialize("LabVirtualMachineList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -139,20 +875,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.LabVirtualMachine" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.LabVirtualMachine": """Get virtual machine. :param resource_group_name: The name of the resource group. @@ -174,30 +911,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,49 +937,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - lab_virtual_machine, # type: "_models.LabVirtualMachine" - **kwargs # type: Any - ): - # type: (...) -> "_models.LabVirtualMachine" + resource_group_name: str, + lab_name: str, + name: str, + lab_virtual_machine: "_models.LabVirtualMachine", + **kwargs: Any + ) -> "_models.LabVirtualMachine": cls = kwargs.pop('cls', None) # type: ClsType["_models.LabVirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(lab_virtual_machine, 'LabVirtualMachine') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_virtual_machine, 'LabVirtualMachine') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -271,17 +988,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - lab_virtual_machine, # type: "_models.LabVirtualMachine" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.LabVirtualMachine"] + resource_group_name: str, + lab_name: str, + name: str, + lab_virtual_machine: "_models.LabVirtualMachine", + **kwargs: Any + ) -> LROPoller["_models.LabVirtualMachine"]: """Create or replace an existing virtual machine. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -294,15 +1013,19 @@ def begin_create_or_update( :type lab_virtual_machine: ~azure.mgmt.devtestlabs.models.LabVirtualMachine :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either LabVirtualMachine or the result of cls(response) + :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 LabVirtualMachine or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devtestlabs.models.LabVirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LabVirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -315,28 +1038,21 @@ def begin_create_or_update( lab_name=lab_name, name=name, lab_virtual_machine=lab_virtual_machine, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('LabVirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -348,43 +1064,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -397,14 +1103,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete virtual machine. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -415,15 +1122,17 @@ def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -438,22 +1147,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -465,17 +1166,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - lab_virtual_machine, # type: "_models.LabVirtualMachineFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.LabVirtualMachine" + resource_group_name: str, + lab_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.LabVirtualMachine": """Allows modifying tags of virtual machines. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -484,8 +1186,8 @@ def update( :type lab_name: str :param name: The name of the virtual machine. :type name: str - :param lab_virtual_machine: A virtual machine. - :type lab_virtual_machine: ~azure.mgmt.devtestlabs.models.LabVirtualMachineFragment + :param tags: The tags of the resource. + :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response :return: LabVirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.devtestlabs.models.LabVirtualMachine @@ -496,33 +1198,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _lab_virtual_machine = _models.LabVirtualMachineFragment(tags=tags) + _json = self._serialize.body(_lab_virtual_machine, 'LabVirtualMachineFragment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_virtual_machine, 'LabVirtualMachineFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -536,49 +1229,40 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'} # type: ignore + def _add_data_disk_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - data_disk_properties, # type: "_models.DataDiskProperties" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + data_disk_properties: "_models.DataDiskProperties", + **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 = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._add_data_disk_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(data_disk_properties, 'DataDiskProperties') + + request = build_add_data_disk_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._add_data_disk_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_disk_properties, 'DataDiskProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -591,15 +1275,16 @@ def _add_data_disk_initial( _add_data_disk_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk'} # type: ignore + + @distributed_trace def begin_add_data_disk( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - data_disk_properties, # type: "_models.DataDiskProperties" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + data_disk_properties: "_models.DataDiskProperties", + **kwargs: Any + ) -> LROPoller[None]: """Attach a new or existing data disk to virtual machine. This operation can take a while to complete. @@ -614,15 +1299,18 @@ def begin_add_data_disk( :type data_disk_properties: ~azure.mgmt.devtestlabs.models.DataDiskProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -635,25 +1323,18 @@ def begin_add_data_disk( lab_name=lab_name, name=name, data_disk_properties=data_disk_properties, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -665,51 +1346,40 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_add_data_disk.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk'} # type: ignore def _apply_artifacts_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - artifacts=None, # type: Optional[List["_models.ArtifactInstallProperties"]] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + artifacts: Optional[List["_models.ArtifactInstallProperties"]] = 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', {})) - _apply_artifacts_request = _models.ApplyArtifactsRequest(artifacts=artifacts) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._apply_artifacts_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _apply_artifacts_request = _models.ApplyArtifactsRequest(artifacts=artifacts) + _json = self._serialize.body(_apply_artifacts_request, 'ApplyArtifactsRequest') + + request = build_apply_artifacts_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._apply_artifacts_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_apply_artifacts_request, 'ApplyArtifactsRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -722,15 +1392,16 @@ def _apply_artifacts_initial( _apply_artifacts_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts'} # type: ignore + + @distributed_trace def begin_apply_artifacts( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - artifacts=None, # type: Optional[List["_models.ArtifactInstallProperties"]] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + artifacts: Optional[List["_models.ArtifactInstallProperties"]] = None, + **kwargs: Any + ) -> LROPoller[None]: """Apply artifacts to virtual machine. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -743,15 +1414,18 @@ def begin_apply_artifacts( :type artifacts: list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties] :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -764,25 +1438,18 @@ def begin_apply_artifacts( lab_name=lab_name, name=name, artifacts=artifacts, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -794,43 +1461,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_apply_artifacts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts'} # type: ignore def _claim_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._claim_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_claim_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._claim_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -843,14 +1500,15 @@ def _claim_initial( _claim_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim'} # type: ignore + + @distributed_trace def begin_claim( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Take ownership of an existing virtual machine This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -861,15 +1519,17 @@ def begin_claim( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -884,22 +1544,14 @@ def begin_claim( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -911,51 +1563,40 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_claim.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim'} # type: ignore def _detach_data_disk_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - existing_lab_disk_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + existing_lab_disk_id: Optional[str] = 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', {})) - _detach_data_disk_properties = _models.DetachDataDiskProperties(existing_lab_disk_id=existing_lab_disk_id) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._detach_data_disk_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _detach_data_disk_properties = _models.DetachDataDiskProperties(existing_lab_disk_id=existing_lab_disk_id) + _json = self._serialize.body(_detach_data_disk_properties, 'DetachDataDiskProperties') + + request = build_detach_data_disk_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._detach_data_disk_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_detach_data_disk_properties, 'DetachDataDiskProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -968,15 +1609,16 @@ def _detach_data_disk_initial( _detach_data_disk_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk'} # type: ignore + + @distributed_trace def begin_detach_data_disk( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - existing_lab_disk_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + existing_lab_disk_id: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Detach the specified disk from the virtual machine. This operation can take a while to complete. @@ -990,15 +1632,18 @@ def begin_detach_data_disk( :type existing_lab_disk_id: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1011,25 +1656,18 @@ def begin_detach_data_disk( lab_name=lab_name, name=name, existing_lab_disk_id=existing_lab_disk_id, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1041,16 +1679,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_detach_data_disk.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk'} # type: ignore + @distributed_trace def get_rdp_file_contents( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RdpConnection" + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> "_models.RdpConnection": """Gets a string that represents the contents of the RDP file for the virtual machine. :param resource_group_name: The name of the resource group. @@ -1069,28 +1708,18 @@ def get_rdp_file_contents( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get_rdp_file_contents.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_rdp_file_contents_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.get_rdp_file_contents.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1104,16 +1733,18 @@ def get_rdp_file_contents( return cls(pipeline_response, deserialized, {}) return deserialized + get_rdp_file_contents.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/getRdpFileContents'} # type: ignore + + @distributed_trace def list_applicable_schedules( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicableSchedule" + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> "_models.ApplicableSchedule": """Lists the applicable start/stop schedules, if any. :param resource_group_name: The name of the resource group. @@ -1132,28 +1763,18 @@ def list_applicable_schedules( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.list_applicable_schedules.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_applicable_schedules_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self.list_applicable_schedules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1167,43 +1788,34 @@ def list_applicable_schedules( return cls(pipeline_response, deserialized, {}) return deserialized + list_applicable_schedules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/listApplicableSchedules'} # type: ignore + def _redeploy_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._redeploy_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_redeploy_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._redeploy_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1216,14 +1828,15 @@ def _redeploy_initial( _redeploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/redeploy'} # type: ignore + + @distributed_trace def begin_redeploy( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Redeploy a virtual machine This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -1234,15 +1847,17 @@ def begin_redeploy( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1257,22 +1872,14 @@ def begin_redeploy( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1284,51 +1891,40 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_redeploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/redeploy'} # type: ignore def _resize_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - size=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + name: str, + size: Optional[str] = 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', {})) - _resize_lab_virtual_machine_properties = _models.ResizeLabVirtualMachineProperties(size=size) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._resize_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _resize_lab_virtual_machine_properties = _models.ResizeLabVirtualMachineProperties(size=size) + _json = self._serialize.body(_resize_lab_virtual_machine_properties, 'ResizeLabVirtualMachineProperties') + + request = build_resize_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._resize_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_resize_lab_virtual_machine_properties, 'ResizeLabVirtualMachineProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1341,15 +1937,16 @@ def _resize_initial( _resize_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/resize'} # type: ignore + + @distributed_trace def begin_resize( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - size=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + size: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Resize Virtual Machine. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -1362,15 +1959,18 @@ def begin_resize( :type size: 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1383,25 +1983,18 @@ def begin_resize( lab_name=lab_name, name=name, size=size, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1413,43 +2006,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_resize.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/resize'} # type: ignore def _restart_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._restart_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_restart_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._restart_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1462,14 +2045,15 @@ def _restart_initial( _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/restart'} # type: ignore + + @distributed_trace def begin_restart( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Restart a virtual machine. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -1480,15 +2064,17 @@ def begin_restart( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1503,22 +2089,14 @@ def begin_restart( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1530,43 +2108,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/restart'} # type: ignore def _start_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1579,14 +2147,15 @@ def _start_initial( _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start'} # type: ignore + + @distributed_trace def begin_start( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Start a virtual machine. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -1597,15 +2166,17 @@ def begin_start( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1620,22 +2191,14 @@ def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1647,43 +2210,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start'} # type: ignore def _stop_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1696,14 +2249,15 @@ def _stop_initial( _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop'} # type: ignore + + @distributed_trace def begin_stop( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Stop a virtual machine This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -1714,15 +2268,17 @@ def begin_stop( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1737,22 +2293,14 @@ def begin_stop( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1764,43 +2312,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop'} # type: ignore def _transfer_disks_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._transfer_disks_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_transfer_disks_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._transfer_disks_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1813,14 +2351,15 @@ def _transfer_disks_initial( _transfer_disks_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/transferDisks'} # type: ignore + + @distributed_trace def begin_transfer_disks( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Transfers all data disks attached to the virtual machine to be owned by the current user. This operation can take a while to complete. @@ -1832,15 +2371,17 @@ def begin_transfer_disks( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1855,22 +2396,14 @@ def begin_transfer_disks( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1882,43 +2415,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_transfer_disks.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/transferDisks'} # type: ignore def _un_claim_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._un_claim_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_un_claim_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._un_claim_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1931,14 +2454,15 @@ def _un_claim_initial( _un_claim_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/unClaim'} # type: ignore + + @distributed_trace def begin_un_claim( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Release ownership of an existing virtual machine This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -1949,15 +2473,17 @@ def begin_un_claim( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1972,22 +2498,14 @@ def begin_un_claim( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1999,4 +2517,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_un_claim.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/unClaim'} # type: ignore diff --git a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_networks_operations.py b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_networks_operations.py index 578ae36c52fe..ad58b5e75064 100644 --- a/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_networks_operations.py +++ b/sdk/devtestlabs/azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/operations/_virtual_networks_operations.py @@ -5,25 +5,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_list_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + 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_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + 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, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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, + lab_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str'), + "name": _SERIALIZER.url("name", 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 + ) class VirtualNetworksOperations(object): """VirtualNetworksOperations operations. @@ -47,17 +268,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualNetworkList"] + resource_group_name: str, + lab_name: str, + expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.VirtualNetworkList"]: """List virtual networks in a given lab. :param resource_group_name: The name of the resource group. @@ -83,44 +304,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + expand=expand, + filter=filter, + top=top, + orderby=orderby, + 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('VirtualNetworkList', pipeline_response) + deserialized = self._deserialize("VirtualNetworkList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,20 +356,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetwork" + resource_group_name: str, + lab_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.VirtualNetwork": """Get virtual network. :param resource_group_name: The name of the resource group. @@ -172,30 +391,19 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,49 +417,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - virtual_network, # type: "_models.VirtualNetwork" - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetwork" + resource_group_name: str, + lab_name: str, + name: str, + virtual_network: "_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 = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(virtual_network, 'VirtualNetwork') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(virtual_network, 'VirtualNetwork') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,17 +468,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - virtual_network, # type: "_models.VirtualNetwork" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VirtualNetwork"] + resource_group_name: str, + lab_name: str, + name: str, + virtual_network: "_models.VirtualNetwork", + **kwargs: Any + ) -> LROPoller["_models.VirtualNetwork"]: """Create or replace an existing virtual network. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -292,15 +493,19 @@ def begin_create_or_update( :type virtual_network: ~azure.mgmt.devtestlabs.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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either VirtualNetwork or the result of cls(response) + :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.devtestlabs.models.VirtualNetwork] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] lro_delay = kwargs.pop( 'polling_interval', @@ -313,28 +518,21 @@ def begin_create_or_update( lab_name=lab_name, name=name, virtual_network=virtual_network, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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 - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -346,43 +544,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + 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 = "2018-09-15" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,14 +583,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + lab_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete virtual network. This operation can take a while to complete. :param resource_group_name: The name of the resource group. @@ -413,15 +602,17 @@ def begin_delete( :type 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: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -436,22 +627,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -463,17 +646,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - lab_name, # type: str - name, # type: str - virtual_network, # type: "_models.VirtualNetworkFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetwork" + resource_group_name: str, + lab_name: str, + name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> "_models.VirtualNetwork": """Allows modifying tags of virtual networks. All other properties will be ignored. :param resource_group_name: The name of the resource group. @@ -482,8 +666,8 @@ def update( :type lab_name: str :param name: The name of the virtual network. :type name: str - :param virtual_network: A virtual network. - :type virtual_network: ~azure.mgmt.devtestlabs.models.VirtualNetworkFragment + :param tags: The tags of the resource. + :type tags: dict[str, 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.devtestlabs.models.VirtualNetwork @@ -494,33 +678,24 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _virtual_network = _models.VirtualNetworkFragment(tags=tags) + _json = self._serialize.body(_virtual_network, 'VirtualNetworkFragment') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(virtual_network, 'VirtualNetworkFragment') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -534,4 +709,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}'} # type: ignore +