diff --git a/sdk/labservices/azure-mgmt-labservices/CHANGELOG.md b/sdk/labservices/azure-mgmt-labservices/CHANGELOG.md index f3cc128d6a3a..b83758d407db 100644 --- a/sdk/labservices/azure-mgmt-labservices/CHANGELOG.md +++ b/sdk/labservices/azure-mgmt-labservices/CHANGELOG.md @@ -1,5 +1,97 @@ # Release History +## 2.0.0b1 (2022-01-18) + +**Features** + + - Added operation LabsOperations.begin_create_or_update + - Added operation LabsOperations.begin_publish + - Added operation LabsOperations.begin_sync_group + - Added operation LabsOperations.begin_update + - Added operation LabsOperations.list_by_resource_group + - Added operation LabsOperations.list_by_subscription + - Added operation Operations.list + - Added operation UsersOperations.begin_create_or_update + - Added operation UsersOperations.begin_invite + - Added operation UsersOperations.begin_update + - Added operation UsersOperations.list_by_lab + - Added operation group ImagesOperations + - Added operation group LabPlansOperations + - Added operation group OperationResultsOperations + - Added operation group SchedulesOperations + - Added operation group SkusOperations + - Added operation group UsagesOperations + - Added operation group VirtualMachinesOperations + - Model Lab has a new parameter auto_shutdown_profile + - Model Lab has a new parameter connection_profile + - Model Lab has a new parameter description + - Model Lab has a new parameter lab_plan_id + - Model Lab has a new parameter network_profile + - Model Lab has a new parameter roster_profile + - Model Lab has a new parameter security_profile + - Model Lab has a new parameter state + - Model Lab has a new parameter system_data + - Model Lab has a new parameter title + - Model Lab has a new parameter virtual_machine_profile + - Model OperationResult has a new parameter end_time + - Model OperationResult has a new parameter id + - Model OperationResult has a new parameter name + - Model OperationResult has a new parameter percent_complete + - Model OperationResult has a new parameter start_time + - Model User has a new parameter additional_usage_quota + - Model User has a new parameter display_name + - Model User has a new parameter invitation_sent + - Model User has a new parameter invitation_state + - Model User has a new parameter registration_state + - Model User has a new parameter system_data + +**Breaking changes** + + - Model Lab no longer has parameter created_by_object_id + - Model Lab no longer has parameter created_by_user_principal_name + - Model Lab no longer has parameter created_date + - Model Lab no longer has parameter invitation_code + - Model Lab no longer has parameter latest_operation_result + - Model Lab no longer has parameter max_users_in_lab + - Model Lab no longer has parameter unique_identifier + - Model Lab no longer has parameter usage_quota + - Model Lab no longer has parameter user_access_mode + - Model Lab no longer has parameter user_quota + - Model Resource no longer has parameter location + - Model Resource no longer has parameter tags + - Model User no longer has parameter family_name + - Model User no longer has parameter given_name + - Model User no longer has parameter latest_operation_result + - Model User no longer has parameter location + - Model User no longer has parameter tags + - Model User no longer has parameter tenant_id + - Model User no longer has parameter unique_identifier + - Operation LabsOperations.begin_delete has a new signature + - Operation LabsOperations.get has a new signature + - Operation LabsOperations.get has a new signature + - Operation UsersOperations.begin_delete has a new signature + - Operation UsersOperations.get has a new signature + - Operation UsersOperations.get has a new signature + - Parameter email of model User is now required + - Parameter email of model User is now required + - Parameter location of model Lab is now required + - Parameter status of model OperationResult is now required + - Removed operation LabsOperations.add_users + - Removed operation LabsOperations.create_or_update + - Removed operation LabsOperations.list + - Removed operation LabsOperations.register + - Removed operation LabsOperations.update + - Removed operation Operations.get + - Removed operation UsersOperations.create_or_update + - Removed operation UsersOperations.list + - Removed operation UsersOperations.update + - Removed operation group EnvironmentSettingsOperations + - Removed operation group EnvironmentsOperations + - Removed operation group GalleryImagesOperations + - Removed operation group GlobalUsersOperations + - Removed operation group LabAccountsOperations + - Removed operation group ProviderOperationsOperations + ## 1.0.0 (2021-03-31) - GA release diff --git a/sdk/labservices/azure-mgmt-labservices/_meta.json b/sdk/labservices/azure-mgmt-labservices/_meta.json index f073a3aeb38a..76f55a99b5d4 100644 --- a/sdk/labservices/azure-mgmt-labservices/_meta.json +++ b/sdk/labservices/azure-mgmt-labservices/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.0.6369", - "use": "@autorest/python@5.6.2", - "commit": "90167a86aca9eed5d51c299b262212738e233e2a", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "2fd8d844ff4be936d818b7ec7c1b4bd668bbeddb", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/labservices/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.2 --version=3.0.6369", + "autorest_command": "autorest specification/labservices/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/labservices/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/__init__.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/__init__.py index 254c16b251dd..6c21b29185d9 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/__init__.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/__init__.py @@ -6,14 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._managed_labs_client import ManagedLabsClient +from ._lab_services_client import LabServicesClient from ._version import VERSION __version__ = VERSION -__all__ = ['ManagedLabsClient'] +__all__ = ['LabServicesClient'] -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/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_configuration.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_configuration.py index 4e55c44cfa8b..5142abd3893f 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_configuration.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_configuration.py @@ -6,49 +6,46 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class ManagedLabsClientConfiguration(Configuration): - """Configuration for ManagedLabsClient. +class LabServicesClientConfiguration(Configuration): + """Configuration for LabServicesClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The ID of the target subscription. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(LabServicesClientConfiguration, 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(ManagedLabsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-10-15" + self.api_version = "2021-11-15-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-labservices/{}'.format(VERSION)) self._configure(**kwargs) @@ -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/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_lab_services_client.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_lab_services_client.py new file mode 100644 index 000000000000..4316ab78f6fb --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_lab_services_client.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, 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 LabServicesClientConfiguration +from .operations import ImagesOperations, LabPlansOperations, LabsOperations, OperationResultsOperations, Operations, SchedulesOperations, SkusOperations, UsagesOperations, UsersOperations, VirtualMachinesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class LabServicesClient: + """REST API for managing Azure Lab Services images. + + :ivar images: ImagesOperations operations + :vartype images: azure.mgmt.labservices.operations.ImagesOperations + :ivar lab_plans: LabPlansOperations operations + :vartype lab_plans: azure.mgmt.labservices.operations.LabPlansOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.labservices.operations.Operations + :ivar labs: LabsOperations operations + :vartype labs: azure.mgmt.labservices.operations.LabsOperations + :ivar operation_results: OperationResultsOperations operations + :vartype operation_results: azure.mgmt.labservices.operations.OperationResultsOperations + :ivar schedules: SchedulesOperations operations + :vartype schedules: azure.mgmt.labservices.operations.SchedulesOperations + :ivar users: UsersOperations operations + :vartype users: azure.mgmt.labservices.operations.UsersOperations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.labservices.operations.VirtualMachinesOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.labservices.operations.UsagesOperations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.labservices.operations.SkusOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = LabServicesClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.lab_plans = LabPlansOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.labs = LabsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_results = OperationResultsOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedules = SchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> LabServicesClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_managed_labs_client.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_managed_labs_client.py deleted file mode 100644 index b132f533cb7a..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_managed_labs_client.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - -from ._configuration import ManagedLabsClientConfiguration -from .operations import ProviderOperationsOperations -from .operations import GlobalUsersOperations -from .operations import LabAccountsOperations -from .operations import Operations -from .operations import GalleryImagesOperations -from .operations import LabsOperations -from .operations import EnvironmentSettingsOperations -from .operations import EnvironmentsOperations -from .operations import UsersOperations -from . import models - - -class ManagedLabsClient(object): - """The Managed Labs Client. - - :ivar provider_operations: ProviderOperationsOperations operations - :vartype provider_operations: azure.mgmt.labservices.operations.ProviderOperationsOperations - :ivar global_users: GlobalUsersOperations operations - :vartype global_users: azure.mgmt.labservices.operations.GlobalUsersOperations - :ivar lab_accounts: LabAccountsOperations operations - :vartype lab_accounts: azure.mgmt.labservices.operations.LabAccountsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.labservices.operations.Operations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.labservices.operations.GalleryImagesOperations - :ivar labs: LabsOperations operations - :vartype labs: azure.mgmt.labservices.operations.LabsOperations - :ivar environment_settings: EnvironmentSettingsOperations operations - :vartype environment_settings: azure.mgmt.labservices.operations.EnvironmentSettingsOperations - :ivar environments: EnvironmentsOperations operations - :vartype environments: azure.mgmt.labservices.operations.EnvironmentsOperations - :ivar users: UsersOperations operations - :vartype users: azure.mgmt.labservices.operations.UsersOperations - :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. - """ - - 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 = ManagedLabsClientConfiguration(credential, 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.provider_operations = ProviderOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.global_users = GlobalUsersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.lab_accounts = LabAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.labs = LabsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.environment_settings = EnvironmentSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.environments = EnvironmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> ManagedLabsClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_metadata.json b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_metadata.json index 0486756d139e..528c60f96895 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_metadata.json +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2018-10-15", - "total_api_version_list": ["2018-10-15"], + "chosen_version": "2021-11-15-preview", + "total_api_version_list": ["2021-11-15-preview"], "client": { - "name": "ManagedLabsClient", - "filename": "_managed_labs_client", - "description": "The Managed Labs Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "name": "LabServicesClient", + "filename": "_lab_services_client", + "description": "REST API for managing Azure Lab Services images.", + "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\": [\"ManagedLabsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagedLabsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "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\": [\"LabServicesClientConfiguration\"]}}, \"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\": [\"LabServicesClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -23,7 +23,7 @@ }, "subscription_id": { "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "description": "The ID of the target subscription.", "docstring_type": "str", "required": true } @@ -37,7 +37,7 @@ }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The ID of the target subscription.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,27 +91,21 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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", - "global_users": "GlobalUsersOperations", - "lab_accounts": "LabAccountsOperations", + "images": "ImagesOperations", + "lab_plans": "LabPlansOperations", "operations": "Operations", - "gallery_images": "GalleryImagesOperations", "labs": "LabsOperations", - "environment_settings": "EnvironmentSettingsOperations", - "environments": "EnvironmentsOperations", - "users": "UsersOperations" - }, - "operation_mixins": { - "sync_imports": "None", - "async_imports": "None", - "operations": { - } + "operation_results": "OperationResultsOperations", + "schedules": "SchedulesOperations", + "users": "UsersOperations", + "virtual_machines": "VirtualMachinesOperations", + "usages": "UsagesOperations", + "skus": "SkusOperations" } } \ No newline at end of file diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_patch.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_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/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_vendor.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_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/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_version.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_version.py index c47f66669f1b..e32dc6ec4218 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_version.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "2.0.0b1" diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/__init__.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/__init__.py index 0058746dccb3..fa404ff18f8b 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/__init__.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/__init__.py @@ -6,5 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._managed_labs_client import ManagedLabsClient -__all__ = ['ManagedLabsClient'] +from ._lab_services_client import LabServicesClient +__all__ = ['LabServicesClient'] + +# `._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/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_configuration.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_configuration.py index ea297364f7eb..44f7e1f97102 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_configuration.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,15 +19,15 @@ from azure.core.credentials_async import AsyncTokenCredential -class ManagedLabsClientConfiguration(Configuration): - """Configuration for ManagedLabsClient. +class LabServicesClientConfiguration(Configuration): + """Configuration for LabServicesClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The ID of the target subscription. :type subscription_id: str """ @@ -37,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(LabServicesClientConfiguration, 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(ManagedLabsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-10-15" + self.api_version = "2021-11-15-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-labservices/{}'.format(VERSION)) self._configure(**kwargs) @@ -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/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_lab_services_client.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_lab_services_client.py new file mode 100644 index 000000000000..07f03fe0fd4b --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_lab_services_client.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, 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 LabServicesClientConfiguration +from .operations import ImagesOperations, LabPlansOperations, LabsOperations, OperationResultsOperations, Operations, SchedulesOperations, SkusOperations, UsagesOperations, UsersOperations, VirtualMachinesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class LabServicesClient: + """REST API for managing Azure Lab Services images. + + :ivar images: ImagesOperations operations + :vartype images: azure.mgmt.labservices.aio.operations.ImagesOperations + :ivar lab_plans: LabPlansOperations operations + :vartype lab_plans: azure.mgmt.labservices.aio.operations.LabPlansOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.labservices.aio.operations.Operations + :ivar labs: LabsOperations operations + :vartype labs: azure.mgmt.labservices.aio.operations.LabsOperations + :ivar operation_results: OperationResultsOperations operations + :vartype operation_results: azure.mgmt.labservices.aio.operations.OperationResultsOperations + :ivar schedules: SchedulesOperations operations + :vartype schedules: azure.mgmt.labservices.aio.operations.SchedulesOperations + :ivar users: UsersOperations operations + :vartype users: azure.mgmt.labservices.aio.operations.UsersOperations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.labservices.aio.operations.VirtualMachinesOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.labservices.aio.operations.UsagesOperations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.labservices.aio.operations.SkusOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = LabServicesClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.lab_plans = LabPlansOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.labs = LabsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_results = OperationResultsOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedules = SchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "LabServicesClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_managed_labs_client.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_managed_labs_client.py deleted file mode 100644 index 51ce40608437..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_managed_labs_client.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Optional, TYPE_CHECKING - -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import ManagedLabsClientConfiguration -from .operations import ProviderOperationsOperations -from .operations import GlobalUsersOperations -from .operations import LabAccountsOperations -from .operations import Operations -from .operations import GalleryImagesOperations -from .operations import LabsOperations -from .operations import EnvironmentSettingsOperations -from .operations import EnvironmentsOperations -from .operations import UsersOperations -from .. import models - - -class ManagedLabsClient(object): - """The Managed Labs Client. - - :ivar provider_operations: ProviderOperationsOperations operations - :vartype provider_operations: azure.mgmt.labservices.aio.operations.ProviderOperationsOperations - :ivar global_users: GlobalUsersOperations operations - :vartype global_users: azure.mgmt.labservices.aio.operations.GlobalUsersOperations - :ivar lab_accounts: LabAccountsOperations operations - :vartype lab_accounts: azure.mgmt.labservices.aio.operations.LabAccountsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.labservices.aio.operations.Operations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.labservices.aio.operations.GalleryImagesOperations - :ivar labs: LabsOperations operations - :vartype labs: azure.mgmt.labservices.aio.operations.LabsOperations - :ivar environment_settings: EnvironmentSettingsOperations operations - :vartype environment_settings: azure.mgmt.labservices.aio.operations.EnvironmentSettingsOperations - :ivar environments: EnvironmentsOperations operations - :vartype environments: azure.mgmt.labservices.aio.operations.EnvironmentsOperations - :ivar users: UsersOperations operations - :vartype users: azure.mgmt.labservices.aio.operations.UsersOperations - :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. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: Optional[str] = None, - **kwargs: Any - ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ManagedLabsClientConfiguration(credential, 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.provider_operations = ProviderOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.global_users = GlobalUsersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.lab_accounts = LabAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.labs = LabsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.environment_settings = EnvironmentSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.environments = EnvironmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "ManagedLabsClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_patch.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/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/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/__init__.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/__init__.py index bfdfe669911b..f4c911b36ab4 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/__init__.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/__init__.py @@ -6,24 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._provider_operations_operations import ProviderOperationsOperations -from ._global_users_operations import GlobalUsersOperations -from ._lab_accounts_operations import LabAccountsOperations +from ._images_operations import ImagesOperations +from ._lab_plans_operations import LabPlansOperations from ._operations import Operations -from ._gallery_images_operations import GalleryImagesOperations from ._labs_operations import LabsOperations -from ._environment_settings_operations import EnvironmentSettingsOperations -from ._environments_operations import EnvironmentsOperations +from ._operation_results_operations import OperationResultsOperations +from ._schedules_operations import SchedulesOperations from ._users_operations import UsersOperations +from ._virtual_machines_operations import VirtualMachinesOperations +from ._usages_operations import UsagesOperations +from ._skus_operations import SkusOperations __all__ = [ - 'ProviderOperationsOperations', - 'GlobalUsersOperations', - 'LabAccountsOperations', + 'ImagesOperations', + 'LabPlansOperations', 'Operations', - 'GalleryImagesOperations', 'LabsOperations', - 'EnvironmentSettingsOperations', - 'EnvironmentsOperations', + 'OperationResultsOperations', + 'SchedulesOperations', 'UsersOperations', + 'VirtualMachinesOperations', + 'UsagesOperations', + 'SkusOperations', ] diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_environment_settings_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_environment_settings_operations.py deleted file mode 100644 index c1fe98f96712..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_environment_settings_operations.py +++ /dev/null @@ -1,934 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class EnvironmentSettingsOperations: - """EnvironmentSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ResponseWithContinuationEnvironmentSetting"]: - """List environment setting in a given lab. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param expand: Specify the $expand query. Example: 'properties($select=publishingState)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationEnvironmentSetting or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationEnvironmentSetting] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationEnvironmentSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationEnvironmentSetting', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings'} # type: ignore - - async def get( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - expand: Optional[str] = None, - **kwargs - ) -> "_models.EnvironmentSetting": - """Get environment setting. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param expand: Specify the $expand query. Example: 'properties($select=publishingState)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnvironmentSetting, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.EnvironmentSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnvironmentSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EnvironmentSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_setting: "_models.EnvironmentSetting", - **kwargs - ) -> "_models.EnvironmentSetting": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnvironmentSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_setting, 'EnvironmentSetting') - 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 - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('EnvironmentSetting', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('EnvironmentSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - async def begin_create_or_update( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_setting: "_models.EnvironmentSetting", - **kwargs - ) -> AsyncLROPoller["_models.EnvironmentSetting"]: - """Create or replace an existing Environment Setting. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_setting: Represents settings of an environment, from which environment - instances would be created. - :type environment_setting: ~azure.mgmt.labservices.models.EnvironmentSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 EnvironmentSetting or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.labservices.models.EnvironmentSetting] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnvironmentSetting"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_setting=environment_setting, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('EnvironmentSetting', 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - async def _delete_initial( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - **kwargs - ) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = self._client.delete(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 [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - async def begin_delete( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Delete environment setting. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - async def update( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_setting: "_models.EnvironmentSettingFragment", - **kwargs - ) -> "_models.EnvironmentSetting": - """Modify properties of environment setting. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_setting: Represents settings of an environment, from which environment - instances would be created. - :type environment_setting: ~azure.mgmt.labservices.models.EnvironmentSettingFragment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnvironmentSetting, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.EnvironmentSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnvironmentSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_setting, 'EnvironmentSettingFragment') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EnvironmentSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - async def claim_any( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - **kwargs - ) -> None: - """Claims a random environment for a user in an environment settings. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.claim_any.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - claim_any.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/claimAny'} # type: ignore - - async def publish( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - publish_payload: "_models.PublishPayload", - **kwargs - ) -> None: - """Provisions/deprovisions required resources for an environment setting based on current state of - the lab/environment setting. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param publish_payload: Payload for Publish operation on EnvironmentSetting. - :type publish_payload: ~azure.mgmt.labservices.models.PublishPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.publish.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(publish_payload, 'PublishPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/publish'} # type: ignore - - async def _start_initial( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - **kwargs - ) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = self._client.post(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/start'} # type: ignore - - async def begin_start( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Starts a template by starting all resources inside the template. This operation can take a - while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._start_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/start'} # type: ignore - - async def _stop_initial( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - **kwargs - ) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = self._client.post(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/stop'} # type: ignore - - async def begin_stop( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Starts a template by starting all resources inside the template. This operation can take a - while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._stop_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/stop'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_environments_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_environments_operations.py deleted file mode 100644 index a2592f642b74..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_environments_operations.py +++ /dev/null @@ -1,976 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class EnvironmentsOperations: - """EnvironmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ResponseWithContinuationEnvironment"]: - """List environments in a given environment setting. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param expand: Specify the $expand query. Example: 'properties($expand=networkInterface)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationEnvironment or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationEnvironment] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationEnvironment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationEnvironment', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments'} # type: ignore - - async def get( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - expand: Optional[str] = None, - **kwargs - ) -> "_models.Environment": - """Get environment. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :param expand: Specify the $expand query. Example: 'properties($expand=networkInterface)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Environment, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.Environment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Environment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Environment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - environment: "_models.Environment", - **kwargs - ) -> "_models.Environment": - """Create or replace an existing Environment. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :param environment: Represents an environment instance. - :type environment: ~azure.mgmt.labservices.models.Environment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Environment, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.Environment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Environment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment, 'Environment') - 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 - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Environment', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Environment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - async def _delete_initial( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - **kwargs - ) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = self._client.delete(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 [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - async def begin_delete( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Delete environment. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_name=environment_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - async def update( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - environment: "_models.EnvironmentFragment", - **kwargs - ) -> "_models.Environment": - """Modify properties of environments. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :param environment: Represents an environment instance. - :type environment: ~azure.mgmt.labservices.models.EnvironmentFragment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Environment, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.Environment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Environment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment, 'EnvironmentFragment') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Environment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - async def claim( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - **kwargs - ) -> None: - """Claims the environment and assigns it to the user. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.claim.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - claim.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/claim'} # type: ignore - - async def _reset_password_initial( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - reset_password_payload: "_models.ResetPasswordPayload", - **kwargs - ) -> 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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._reset_password_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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(reset_password_payload, 'ResetPasswordPayload') - 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 - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _reset_password_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/resetPassword'} # type: ignore - - async def begin_reset_password( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - reset_password_payload: "_models.ResetPasswordPayload", - **kwargs - ) -> AsyncLROPoller[None]: - """Resets the user password on an environment This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :param reset_password_payload: Represents the payload for resetting passwords. - :type reset_password_payload: ~azure.mgmt.labservices.models.ResetPasswordPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._reset_password_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_name=environment_name, - reset_password_payload=reset_password_payload, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_reset_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/resetPassword'} # type: ignore - - async def _start_initial( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - **kwargs - ) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = self._client.post(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/start'} # type: ignore - - async def begin_start( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Starts an environment by starting all resources inside the environment. This operation can take - a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._start_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_name=environment_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/start'} # type: ignore - - async def _stop_initial( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - **kwargs - ) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = self._client.post(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/stop'} # type: ignore - - async def begin_stop( - self, - resource_group_name: str, - lab_account_name: str, - lab_name: str, - environment_setting_name: str, - environment_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Stops an environment by stopping all resources inside the environment This operation can take a - while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._stop_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_name=environment_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/stop'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_gallery_images_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_gallery_images_operations.py deleted file mode 100644 index e46fe31d8e67..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_gallery_images_operations.py +++ /dev/null @@ -1,406 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from 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.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name: str, - lab_account_name: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ResponseWithContinuationGalleryImage"]: - """List gallery images in a given lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param expand: Specify the $expand query. Example: 'properties($select=author)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationGalleryImage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationGalleryImage] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationGalleryImage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationGalleryImage', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages'} # type: ignore - - async def get( - self, - resource_group_name: str, - lab_account_name: str, - gallery_image_name: str, - expand: Optional[str] = None, - **kwargs - ) -> "_models.GalleryImage": - """Get gallery image. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param gallery_image_name: The name of the gallery Image. - :type gallery_image_name: str - :param expand: Specify the $expand query. Example: 'properties($select=author)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GalleryImage, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GalleryImage - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'galleryImageName': self._serialize.url("gallery_image_name", gallery_image_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 = 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GalleryImage', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - lab_account_name: str, - gallery_image_name: str, - gallery_image: "_models.GalleryImage", - **kwargs - ) -> "_models.GalleryImage": - """Create or replace an existing Gallery Image. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param gallery_image_name: The name of the gallery Image. - :type gallery_image_name: str - :param gallery_image: Represents an image from the Azure Marketplace. - :type gallery_image: ~azure.mgmt.labservices.models.GalleryImage - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GalleryImage, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GalleryImage - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'galleryImageName': self._serialize.url("gallery_image_name", gallery_image_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(gallery_image, 'GalleryImage') - 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 - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('GalleryImage', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('GalleryImage', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - lab_account_name: str, - gallery_image_name: str, - **kwargs - ) -> None: - """Delete gallery image. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param gallery_image_name: The name of the gallery Image. - :type gallery_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'galleryImageName': self._serialize.url("gallery_image_name", gallery_image_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 = self._client.delete(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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}'} # type: ignore - - async def update( - self, - resource_group_name: str, - lab_account_name: str, - gallery_image_name: str, - gallery_image: "_models.GalleryImageFragment", - **kwargs - ) -> "_models.GalleryImage": - """Modify properties of gallery images. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param gallery_image_name: The name of the gallery Image. - :type gallery_image_name: str - :param gallery_image: Represents an image from the Azure Marketplace. - :type gallery_image: ~azure.mgmt.labservices.models.GalleryImageFragment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GalleryImage, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GalleryImage - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'galleryImageName': self._serialize.url("gallery_image_name", gallery_image_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(gallery_image, 'GalleryImageFragment') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GalleryImage', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_global_users_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_global_users_operations.py deleted file mode 100644 index 83cc78202237..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_global_users_operations.py +++ /dev/null @@ -1,797 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class GlobalUsersOperations: - """GlobalUsersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get_environment( - self, - user_name: str, - environment_operations_payload: "_models.EnvironmentOperationsPayload", - expand: Optional[str] = None, - **kwargs - ) -> "_models.GetEnvironmentResponse": - """Gets the virtual machine details. - - :param user_name: The name of the user. - :type user_name: str - :param environment_operations_payload: Represents payload for any Environment operations like - get, start, stop, connect. - :type environment_operations_payload: ~azure.mgmt.labservices.models.EnvironmentOperationsPayload - :param expand: Specify the $expand query. Example: 'properties($expand=environment)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetEnvironmentResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GetEnvironmentResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetEnvironmentResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_environment.metadata['url'] # type: ignore - path_format_arguments = { - '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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_operations_payload, 'EnvironmentOperationsPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GetEnvironmentResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_environment.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/getEnvironment'} # type: ignore - - async def get_operation_batch_status( - self, - user_name: str, - operation_batch_status_payload: "_models.OperationBatchStatusPayload", - **kwargs - ) -> "_models.OperationBatchStatusResponse": - """Get batch operation status. - - :param user_name: The name of the user. - :type user_name: str - :param operation_batch_status_payload: Payload to get the status of an operation. - :type operation_batch_status_payload: ~azure.mgmt.labservices.models.OperationBatchStatusPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationBatchStatusResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.OperationBatchStatusResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationBatchStatusResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_operation_batch_status.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_batch_status_payload, 'OperationBatchStatusPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('OperationBatchStatusResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_operation_batch_status.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/getOperationBatchStatus'} # type: ignore - - async def get_operation_status( - self, - user_name: str, - operation_status_payload: "_models.OperationStatusPayload", - **kwargs - ) -> "_models.OperationStatusResponse": - """Gets the status of long running operation. - - :param user_name: The name of the user. - :type user_name: str - :param operation_status_payload: Payload to get the status of an operation. - :type operation_status_payload: ~azure.mgmt.labservices.models.OperationStatusPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.OperationStatusResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_status_payload, 'OperationStatusPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('OperationStatusResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_operation_status.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/getOperationStatus'} # type: ignore - - async def get_personal_preferences( - self, - user_name: str, - personal_preferences_operations_payload: "_models.PersonalPreferencesOperationsPayload", - **kwargs - ) -> "_models.GetPersonalPreferencesResponse": - """Get personal preferences for a user. - - :param user_name: The name of the user. - :type user_name: str - :param personal_preferences_operations_payload: Represents payload for any Environment - operations like get, start, stop, connect. - :type personal_preferences_operations_payload: ~azure.mgmt.labservices.models.PersonalPreferencesOperationsPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetPersonalPreferencesResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GetPersonalPreferencesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetPersonalPreferencesResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_personal_preferences.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(personal_preferences_operations_payload, 'PersonalPreferencesOperationsPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GetPersonalPreferencesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_personal_preferences.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/getPersonalPreferences'} # type: ignore - - async def list_environments( - self, - user_name: str, - list_environments_payload: "_models.ListEnvironmentsPayload", - **kwargs - ) -> "_models.ListEnvironmentsResponse": - """List Environments for the user. - - :param user_name: The name of the user. - :type user_name: str - :param list_environments_payload: Represents the payload to list environments owned by a user. - :type list_environments_payload: ~azure.mgmt.labservices.models.ListEnvironmentsPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListEnvironmentsResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.ListEnvironmentsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListEnvironmentsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.list_environments.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(list_environments_payload, 'ListEnvironmentsPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ListEnvironmentsResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_environments.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/listEnvironments'} # type: ignore - - async def list_labs( - self, - user_name: str, - **kwargs - ) -> "_models.ListLabsResponse": - """List labs for the user. - - :param user_name: The name of the user. - :type user_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListLabsResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.ListLabsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListLabsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.list_labs.metadata['url'] # type: ignore - path_format_arguments = { - '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] - 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 = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ListLabsResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_labs.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/listLabs'} # type: ignore - - async def register( - self, - user_name: str, - register_payload: "_models.RegisterPayload", - **kwargs - ) -> None: - """Register a user to a managed lab. - - :param user_name: The name of the user. - :type user_name: str - :param register_payload: Represents payload for Register action. - :type register_payload: ~azure.mgmt.labservices.models.RegisterPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(register_payload, 'RegisterPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - register.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/register'} # type: ignore - - async def _reset_password_initial( - self, - user_name: str, - reset_password_payload: "_models.ResetPasswordPayload", - **kwargs - ) -> 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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._reset_password_initial.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(reset_password_payload, 'ResetPasswordPayload') - 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 - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _reset_password_initial.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/resetPassword'} # type: ignore - - async def begin_reset_password( - self, - user_name: str, - reset_password_payload: "_models.ResetPasswordPayload", - **kwargs - ) -> AsyncLROPoller[None]: - """Resets the user password on an environment This operation can take a while to complete. - - :param user_name: The name of the user. - :type user_name: str - :param reset_password_payload: Represents the payload for resetting passwords. - :type reset_password_payload: ~azure.mgmt.labservices.models.ResetPasswordPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._reset_password_initial( - user_name=user_name, - reset_password_payload=reset_password_payload, - 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 = { - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_reset_password.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/resetPassword'} # type: ignore - - async def _start_environment_initial( - self, - user_name: str, - environment_operations_payload: "_models.EnvironmentOperationsPayload", - **kwargs - ) -> 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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._start_environment_initial.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_operations_payload, 'EnvironmentOperationsPayload') - 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 - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _start_environment_initial.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/startEnvironment'} # type: ignore - - async def begin_start_environment( - self, - user_name: str, - environment_operations_payload: "_models.EnvironmentOperationsPayload", - **kwargs - ) -> AsyncLROPoller[None]: - """Starts an environment by starting all resources inside the environment. This operation can take - a while to complete. - - :param user_name: The name of the user. - :type user_name: str - :param environment_operations_payload: Represents payload for any Environment operations like - get, start, stop, connect. - :type environment_operations_payload: ~azure.mgmt.labservices.models.EnvironmentOperationsPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._start_environment_initial( - user_name=user_name, - environment_operations_payload=environment_operations_payload, - 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 = { - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start_environment.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/startEnvironment'} # type: ignore - - async def _stop_environment_initial( - self, - user_name: str, - environment_operations_payload: "_models.EnvironmentOperationsPayload", - **kwargs - ) -> 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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._stop_environment_initial.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_operations_payload, 'EnvironmentOperationsPayload') - 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 - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _stop_environment_initial.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/stopEnvironment'} # type: ignore - - async def begin_stop_environment( - self, - user_name: str, - environment_operations_payload: "_models.EnvironmentOperationsPayload", - **kwargs - ) -> AsyncLROPoller[None]: - """Stops an environment by stopping all resources inside the environment This operation can take a - while to complete. - - :param user_name: The name of the user. - :type user_name: str - :param environment_operations_payload: Represents payload for any Environment operations like - get, start, stop, connect. - :type environment_operations_payload: ~azure.mgmt.labservices.models.EnvironmentOperationsPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._stop_environment_initial( - user_name=user_name, - environment_operations_payload=environment_operations_payload, - 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 = { - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop_environment.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/stopEnvironment'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_images_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_images_operations.py new file mode 100644 index 000000000000..5d523bd83ff4 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_images_operations.py @@ -0,0 +1,322 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._images_operations import build_create_or_update_request, build_get_request, build_list_by_lab_plan_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ImagesOperations: + """ImagesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_lab_plan( + self, + resource_group_name: str, + lab_plan_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PagedImages"]: + """Gets all images. + + Gets all images from galleries attached to a lab plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedImages or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedImages] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedImages"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_lab_plan_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + filter=filter, + template_url=self.list_by_lab_plan.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_lab_plan_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + filter=filter, + 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("PagedImages", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_lab_plan.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + lab_plan_name: str, + image_name: str, + **kwargs: Any + ) -> "_models.Image": + """Gets an image. + + Gets an image resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param image_name: The image name. + :type image_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Image, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.Image + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + image_name=image_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Image', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + lab_plan_name: str, + image_name: str, + body: "_models.Image", + **kwargs: Any + ) -> "_models.Image": + """Updates an image via PUT. + + Updates an image resource via PUT. Creating new resources via PUT will not function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param image_name: The image name. + :type image_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.Image + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Image, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.Image + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'Image') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + image_name=image_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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Image', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + lab_plan_name: str, + image_name: str, + body: "_models.ImageUpdate", + **kwargs: Any + ) -> "_models.Image": + """Updates an image. + + Updates an image resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param image_name: The image name. + :type image_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.ImageUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Image, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.Image + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ImageUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + image_name=image_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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Image', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}'} # type: ignore + diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_lab_accounts_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_lab_accounts_operations.py deleted file mode 100644 index 6963eefada26..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_lab_accounts_operations.py +++ /dev/null @@ -1,649 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class LabAccountsOperations: - """LabAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_subscription( - self, - expand: Optional[str] = None, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ResponseWithContinuationLabAccount"]: - """List lab accounts in a subscription. - - :param expand: Specify the $expand query. Example: 'properties($expand=sizeConfiguration)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationLabAccount or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationLabAccount] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationLabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationLabAccount', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labaccounts'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ResponseWithContinuationLabAccount"]: - """List lab accounts in a resource group. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param expand: Specify the $expand query. Example: 'properties($expand=sizeConfiguration)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationLabAccount or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationLabAccount] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationLabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationLabAccount', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts'} # type: ignore - - async def get( - self, - resource_group_name: str, - lab_account_name: str, - expand: Optional[str] = None, - **kwargs - ) -> "_models.LabAccount": - """Get lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param expand: Specify the $expand query. Example: 'properties($expand=sizeConfiguration)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LabAccount, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.LabAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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 = 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('LabAccount', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - lab_account_name: str, - lab_account: "_models.LabAccount", - **kwargs - ) -> "_models.LabAccount": - """Create or replace an existing Lab Account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_account: Represents a lab account. - :type lab_account: ~azure.mgmt.labservices.models.LabAccount - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LabAccount, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.LabAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_account, 'LabAccount') - 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 - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('LabAccount', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('LabAccount', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - async def _delete_initial( - self, - resource_group_name: str, - lab_account_name: str, - **kwargs - ) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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 = self._client.delete(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 [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - async def begin_delete( - self, - resource_group_name: str, - lab_account_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Delete lab account. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - async def update( - self, - resource_group_name: str, - lab_account_name: str, - lab_account: "_models.LabAccountFragment", - **kwargs - ) -> "_models.LabAccount": - """Modify properties of lab accounts. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_account: Represents a lab account. - :type lab_account: ~azure.mgmt.labservices.models.LabAccountFragment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LabAccount, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.LabAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_account, 'LabAccountFragment') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('LabAccount', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - async def create_lab( - self, - resource_group_name: str, - lab_account_name: str, - create_lab_properties: "_models.CreateLabProperties", - **kwargs - ) -> None: - """Create a lab in a lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param create_lab_properties: Properties for creating a managed lab and a default environment - setting. - :type create_lab_properties: ~azure.mgmt.labservices.models.CreateLabProperties - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_lab.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_lab_properties, 'CreateLabProperties') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - create_lab.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/createLab'} # type: ignore - - async def get_regional_availability( - self, - resource_group_name: str, - lab_account_name: str, - **kwargs - ) -> "_models.GetRegionalAvailabilityResponse": - """Get regional availability information for each size category configured under a lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetRegionalAvailabilityResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GetRegionalAvailabilityResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetRegionalAvailabilityResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.get_regional_availability.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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 = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GetRegionalAvailabilityResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_regional_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/getRegionalAvailability'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_lab_plans_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_lab_plans_operations.py new file mode 100644 index 000000000000..9cf8934b813b --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_lab_plans_operations.py @@ -0,0 +1,707 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._lab_plans_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_save_image_request_initial, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class LabPlansOperations: + """LabPlansOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_subscription( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PagedLabPlans"]: + """Get all lab plans for a subscription. + + Returns a list of all lab plans within a subscription. + + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedLabPlans or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedLabPlans] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabPlans"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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("PagedLabPlans", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labPlans'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.PagedLabPlans"]: + """Get all lab plans for a subscription and resource group. + + Returns a list of all lab plans for a subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedLabPlans or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedLabPlans] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabPlans"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PagedLabPlans", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + lab_plan_name: str, + **kwargs: Any + ) -> "_models.LabPlan": + """Retrieves a Lab Plan resource. + + Retrieves the properties of a Lab Plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LabPlan, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.LabPlan + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LabPlan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.LabPlan", + **kwargs: Any + ) -> "_models.LabPlan": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'LabPlan') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.LabPlan", + **kwargs: Any + ) -> AsyncLROPoller["_models.LabPlan"]: + """Updates or creates a Lab Plan resource. + + Operation to create or update a Lab Plan resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.LabPlan + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LabPlan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.labservices.models.LabPlan] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('LabPlan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.LabPlanUpdate", + **kwargs: Any + ) -> "_models.LabPlan": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'LabPlanUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.LabPlanUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.LabPlan"]: + """Updates a Lab Plan resource. + + Operation to update a Lab Plan resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.LabPlanUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LabPlan or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.labservices.models.LabPlan] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('LabPlan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + lab_plan_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + lab_plan_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a Lab Plan resource. + + Operation to delete a Lab Plan resource. Deleting a lab plan does not delete labs associated + with a lab plan, nor does it delete shared images added to a gallery via the lab plan + permission container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + async def _save_image_initial( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.SaveImageBody", + **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', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'SaveImageBody') + + request = build_save_image_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + content_type=content_type, + json=_json, + template_url=self._save_image_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _save_image_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/saveImage'} # type: ignore + + + @distributed_trace_async + async def begin_save_image( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.SaveImageBody", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Save an image from a lab VM to the attached shared image gallery. + + Saves an image from a lab VM to the attached shared image gallery. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.SaveImageBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._save_image_initial( + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_save_image.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/saveImage'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_labs_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_labs_operations.py index b301b127c4d1..bec533939416 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_labs_operations.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_labs_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._labs_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_publish_request_initial, build_sync_group_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,78 +48,124 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list( + @distributed_trace + def list_by_subscription( self, - resource_group_name: str, - lab_account_name: str, - expand: Optional[str] = None, filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ResponseWithContinuationLab"]: - """List labs in a given lab account. + **kwargs: Any + ) -> AsyncIterable["_models.PagedLabs"]: + """Get all labs for a subscription. + + Returns a list of all labs for a subscription. - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param expand: Specify the $expand query. Example: 'properties($select=maxUsersInLab)'. - :type expand: str :param filter: The filter to apply to the operation. :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationLab or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationLab] + :return: An iterator like instance of either PagedLabs or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedLabs] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationLab"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabs"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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("PagedLabs", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labs'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.PagedLabs"]: + """Get all labs for a subscription and resource group. + + Returns a list of all labs in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedLabs or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedLabs] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabs"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): if not next_link: - # 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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, + 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, + 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('ResponseWithContinuationLab', pipeline_response) + deserialized = self._deserialize("PagedLabs", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,33 +179,33 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs'} # type: ignore + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, - lab_account_name: str, lab_name: str, - expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Lab": - """Get lab. + """Get a lab resource. + + Returns the properties of a lab resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param expand: Specify the $expand query. Example: 'properties($select=maxUsersInLab)'. - :type expand: 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.labservices.models.Lab @@ -165,36 +216,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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') - 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, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Lab', pipeline_response) @@ -202,154 +241,321 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore - async def create_or_update( + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + + async def _create_or_update_initial( self, resource_group_name: str, - lab_account_name: str, lab_name: str, - lab: "_models.Lab", - **kwargs + body: "_models.Lab", + **kwargs: Any ) -> "_models.Lab": - """Create or replace an existing 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', {})) - :param resource_group_name: The name of the resource group. + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'Lab') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Lab', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Lab', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('Lab', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + lab_name: str, + body: "_models.Lab", + **kwargs: Any + ) -> AsyncLROPoller["_models.Lab"]: + """Create or update a lab resource. + + Operation to create or update a lab resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param lab: Represents a lab. - :type lab: ~azure.mgmt.labservices.models.Lab + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.Lab :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.labservices.models.Lab + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Lab or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.labservices.models.Lab] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Lab', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + lab_name: str, + body: "_models.LabUpdate", + **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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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(body, 'LabUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Lab', pipeline_response) - if response.status_code == 201: + if response.status_code == 202: deserialized = self._deserialize('Lab', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + lab_name: str, + body: "_models.LabUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.Lab"]: + """Update a lab resource. + + Operation to update a lab resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.LabUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Lab or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.labservices.models.Lab] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Lab', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore async def _delete_initial( self, resource_group_name: str, - lab_account_name: str, lab_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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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, + 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 - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, - lab_account_name: str, lab_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: - """Delete lab. This operation can take a while to complete. + """Deletes a lab resource. + + Operation to delete a lab resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -359,27 +565,18 @@ async def begin_delete( if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - lab_account_name=lab_account_name, lab_name=lab_name, 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -391,200 +588,204 @@ 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.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore - async def update( + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + async def _publish_initial( self, resource_group_name: str, - lab_account_name: str, lab_name: str, - lab: "_models.LabFragment", - **kwargs - ) -> "_models.Lab": - """Modify properties of labs. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param lab: Represents a lab. - :type lab: ~azure.mgmt.labservices.models.LabFragment - :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.labservices.models.Lab - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] + **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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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') + + request = build_publish_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + template_url=self._publish_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, '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 - 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('Lab', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) + + _publish_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/publish'} # type: ignore - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore - async def add_users( + @distributed_trace_async + async def begin_publish( self, resource_group_name: str, - lab_account_name: str, lab_name: str, - add_users_payload: "_models.AddUsersPayload", - **kwargs - ) -> None: - """Add users to a lab. + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Publish or re-publish a lab. + + Publish or re-publish a lab. This will create or update all lab resources, such as virtual + machines. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param add_users_payload: Payload for Add Users operation on a Lab. - :type add_users_payload: ~azure.mgmt.labservices.models.AddUsersPayload :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._publish_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/publish'} # type: ignore + + async def _sync_group_initial( + self, + resource_group_name: str, + lab_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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.add_users.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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') + + request = build_sync_group_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + template_url=self._sync_group_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(add_users_payload, 'AddUsersPayload') - 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 - 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) if cls: return cls(pipeline_response, None, {}) - add_users.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/addUsers'} # type: ignore + _sync_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/syncGroup'} # type: ignore + - async def register( + @distributed_trace_async + async def begin_sync_group( self, resource_group_name: str, - lab_account_name: str, lab_name: str, - **kwargs - ) -> None: - """Register to managed lab. + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually sync the lab group. + + Action used to manually kick off an AAD group sync job. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.register.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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') + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._sync_group_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) - 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 + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - register.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/register'} # type: ignore + begin_sync_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/syncGroup'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_operation_results_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_operation_results_operations.py new file mode 100644 index 000000000000..e9268ee54665 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_operation_results_operations.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, 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 +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._operation_results_operations import build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationResultsOperations: + """OperationResultsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + operation_result_id: str, + **kwargs: Any + ) -> Optional["_models.OperationResult"]: + """Get an azure operation result. + + Returns an azure operation result. + + :param operation_result_id: The operation result ID / name. + :type operation_result_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationResult, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.OperationResult or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + operation_result_id=operation_result_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/operationResults/{operationResultId}'} # type: ignore + diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_operations.py index ea3bf1faea21..f67c32045850 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_operations.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_operations.py @@ -5,16 +5,22 @@ # 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, 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._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,60 +46,67 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def get( + @distributed_trace + def list( self, - location_name: str, - operation_name: str, - **kwargs - ) -> "_models.OperationResult": - """Get operation. - - :param location_name: The name of the location. - :type location_name: str - :param operation_name: The name of the operation. - :type operation_name: str + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Get all operations. + + Returns a list of all operations. + :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationResult, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.OperationResult + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'operationName': self._serialize.url("operation_name", operation_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 = 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]: - 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 cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/locations/{locationName}/operations/{operationName}'} # type: ignore + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.LabServices/operations'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_schedules_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_schedules_operations.py new file mode 100644 index 000000000000..e62bed319846 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_schedules_operations.py @@ -0,0 +1,437 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._schedules_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_by_lab_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SchedulesOperations: + """SchedulesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_lab( + self, + resource_group_name: str, + lab_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PagedSchedules"]: + """Get all schedules for a lab. + + Returns a list of all schedules for a lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedSchedules or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedSchedules] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedSchedules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + template_url=self.list_by_lab.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + 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("PagedSchedules", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_lab.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + **kwargs: Any + ) -> "_models.Schedule": + """Get a lab Schedule. + + Returns the properties of a lab Schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param schedule_name: The name of the schedule that uniquely identifies it within containing + lab. Used in resource URIs. + :type schedule_name: 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.labservices.models.Schedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Schedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + body: "_models.Schedule", + **kwargs: Any + ) -> "_models.Schedule": + """Create or update a lab schedule. + + Operation to create or update a lab schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param schedule_name: The name of the schedule that uniquely identifies it within containing + lab. Used in resource URIs. + :type schedule_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.Schedule + :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.labservices.models.Schedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'Schedule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Schedule', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Schedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + body: "_models.ScheduleUpdate", + **kwargs: Any + ) -> "_models.Schedule": + """Update a lab schedule. + + Operation to update a lab schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param schedule_name: The name of the schedule that uniquely identifies it within containing + lab. Used in resource URIs. + :type schedule_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.ScheduleUpdate + :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.labservices.models.Schedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ScheduleUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Schedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore + + + async def _delete_initial( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a schedule resource. + + Operation to delete a schedule resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param schedule_name: The name of the schedule that uniquely identifies it within containing + lab. Used in resource URIs. + :type schedule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_provider_operations_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_skus_operations.py similarity index 58% rename from sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_provider_operations_operations.py rename to sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_skus_operations.py index 7008324f2aa6..6519c6755964 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_provider_operations_operations.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_skus_operations.py @@ -5,22 +5,27 @@ # 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._skus_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProviderOperationsOperations: - """ProviderOperationsOperations async operations. +class SkusOperations: + """SkusOperations async operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. @@ -41,46 +46,55 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs - ) -> AsyncIterable["_models.ProviderOperationResult"]: - """Result of the request to list REST API operations. + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PagedLabServicesSkus"]: + """Gets all the Azure Lab Services resource SKUs. + + Returns a list of all the Azure Lab Services resource SKUs. + :param filter: The filter to apply to the operation. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ProviderOperationResult] + :return: An iterator like instance of either PagedLabServicesSkus or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedLabServicesSkus] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabServicesSkus"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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( + subscription_id=self._config.subscription_id, + filter=filter, + 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( + subscription_id=self._config.subscription_id, + filter=filter, + 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("PagedLabServicesSkus", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,11 +108,13 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.LabServices/operations'} # type: ignore + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/skus'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_usages_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_usages_operations.py new file mode 100644 index 000000000000..66213024da88 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_usages_operations.py @@ -0,0 +1,124 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._usages_operations import build_list_by_location_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class UsagesOperations: + """UsagesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_location( + self, + location: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ListUsagesResult"]: + """Gets the list of usages. + + Returns list of usage per SKU family for the specified subscription in the specified region. + + :param location: The location name. + :type location: str + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListUsagesResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ListUsagesResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + filter=filter, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + filter=filter, + 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("ListUsagesResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/locations/{location}/usages'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_users_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_users_operations.py index 012b0a26415c..9972040966d4 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_users_operations.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/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_invite_request_initial, build_list_by_lab_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,82 +48,64 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list( + @distributed_trace + def list_by_lab( self, resource_group_name: str, - lab_account_name: str, lab_name: str, - expand: Optional[str] = None, filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ResponseWithContinuationUser"]: - """List users in a given lab. + **kwargs: Any + ) -> AsyncIterable["_models.PagedUsers"]: + """Get all users for a lab. + + Returns a list of all users for a lab. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param expand: Specify the $expand query. Example: 'properties($select=email)'. - :type expand: str :param filter: The filter to apply to the operation. :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationUser or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationUser] + :return: An iterator like instance of either PagedUsers or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedUsers] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationUser"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedUsers"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + template_url=self.list_by_lab.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_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + 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('ResponseWithContinuationUser', pipeline_response) + deserialized = self._deserialize("PagedUsers", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,36 +119,37 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users'} # type: ignore + list_by_lab.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, - lab_account_name: str, lab_name: str, user_name: str, - expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.User": - """Get user. + """Get a lab user. - :param resource_group_name: The name of the resource group. + Returns the properties of a lab user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param user_name: The name of the user. + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. :type user_name: str - :param expand: Specify the $expand query. Example: 'properties($select=email)'. - :type expand: 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.labservices.models.User @@ -172,37 +160,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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') - 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, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('User', pipeline_response) @@ -210,163 +186,341 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore - async def create_or_update( + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + + async def _create_or_update_initial( self, resource_group_name: str, - lab_account_name: str, lab_name: str, user_name: str, - user: "_models.User", - **kwargs + body: "_models.User", + **kwargs: Any ) -> "_models.User": - """Create or replace an existing 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', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'User') + + 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, + 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) - :param resource_group_name: The name of the resource group. + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('User', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('User', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('User', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.User", + **kwargs: Any + ) -> AsyncLROPoller["_models.User"]: + """Create or update a lab user. + + Operation to create or update a lab user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param user_name: The name of the user. + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. :type user_name: str - :param user: The User registered to a lab. - :type user: ~azure.mgmt.labservices.models.User + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.User :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.labservices.models.User + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.labservices.models.User] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('User', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.UserUpdate", + **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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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(body, 'UserUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('User', pipeline_response) - if response.status_code == 201: + if response.status_code == 202: deserialized = self._deserialize('User', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.UserUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.User"]: + """Update a lab user. + + Operation to update a lab user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. + :type user_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.UserUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.labservices.models.User] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('User', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore async def _delete_initial( self, resource_group_name: str, - lab_account_name: str, lab_name: str, user_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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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, + 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 - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, - lab_account_name: str, lab_name: str, user_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: - """Delete user. This operation can take a while to complete. + """Deletes a user resource. - :param resource_group_name: The name of the resource group. + Operation to delete a user resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param user_name: The name of the user. + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. :type user_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -376,29 +530,19 @@ async def begin_delete( if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - lab_account_name=lab_account_name, lab_name=lab_name, user_name=user_name, 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -410,78 +554,123 @@ 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore - async def update( + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + async def _invite_initial( self, resource_group_name: str, - lab_account_name: str, lab_name: str, user_name: str, - user: "_models.UserFragment", - **kwargs - ) -> "_models.User": - """Modify properties of users. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param user_name: The name of the user. - :type user_name: str - :param user: The User registered to a lab. - :type user: ~azure.mgmt.labservices.models.UserFragment - :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.labservices.models.User - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] + body: "_models.InviteBody", + **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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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(body, 'InviteBody') - # 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_invite_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + content_type=content_type, + json=_json, + template_url=self._invite_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, '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 - 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('User', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore + _invite_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}/invite'} # type: ignore + + + @distributed_trace_async + async def begin_invite( + self, + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.InviteBody", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Invite a user to a lab. + + Operation to invite a user to a lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. + :type user_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.InviteBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._invite_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_invite.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}/invite'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_virtual_machines_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_virtual_machines_operations.py new file mode 100644 index 000000000000..afdad027d2fd --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/aio/operations/_virtual_machines_operations.py @@ -0,0 +1,737 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._virtual_machines_operations import build_get_request, build_list_by_lab_request, build_redeploy_request_initial, build_reimage_request_initial, build_reset_password_request_initial, build_start_request_initial, build_stop_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualMachinesOperations: + """VirtualMachinesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_lab( + self, + resource_group_name: str, + lab_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PagedVirtualMachines"]: + """Get all virtual machines for a lab. + + Returns a list of all virtual machines for a lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedVirtualMachines or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.labservices.models.PagedVirtualMachines] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedVirtualMachines"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + template_url=self.list_by_lab.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + 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("PagedVirtualMachines", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_lab.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> "_models.VirtualMachine": + """Get a lab virtual machine. + + Returns the properties for a lab virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachine, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.VirtualMachine + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}'} # type: ignore + + + async def _start_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/start'} # type: ignore + + + @distributed_trace_async + async def begin_start( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Start a lab virtual machine. + + Action to start a lab virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/start'} # type: ignore + + async def _stop_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/stop'} # type: ignore + + + @distributed_trace_async + async def begin_stop( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Stop a lab virtual machine. + + Action to stop a lab virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._stop_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/stop'} # type: ignore + + async def _reimage_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_reimage_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + template_url=self._reimage_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _reimage_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/reimage'} # type: ignore + + + @distributed_trace_async + async def begin_reimage( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Re-image a lab virtual machine. + + Re-image a lab virtual machine. The virtual machine will be deleted and recreated using the + latest published snapshot of the reference environment of the lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._reimage_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_reimage.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/reimage'} # type: ignore + + async def _redeploy_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_redeploy_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + template_url=self._redeploy_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _redeploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/redeploy'} # type: ignore + + + @distributed_trace_async + async def begin_redeploy( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Redeploy a lab virtual machine to a different compute node. For troubleshooting connectivity. + + Action to redeploy a lab virtual machine to a different compute node. For troubleshooting + connectivity. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._redeploy_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_redeploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/redeploy'} # type: ignore + + async def _reset_password_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + body: "_models.ResetPasswordBody", + **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', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResetPasswordBody') + + request = build_reset_password_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + content_type=content_type, + json=_json, + template_url=self._reset_password_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _reset_password_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/resetPassword'} # type: ignore + + + @distributed_trace_async + async def begin_reset_password( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + body: "_models.ResetPasswordBody", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reset a lab virtual machine password. + + Resets a lab virtual machine password. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.ResetPasswordBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._reset_password_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_reset_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/resetPassword'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/__init__.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/__init__.py index 82f6a1c4b0ee..701e6f0b7671 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/__init__.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/__init__.py @@ -6,228 +6,188 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AddUsersPayload - from ._models_py3 import CloudErrorBody - from ._models_py3 import CreateLabProperties - from ._models_py3 import Environment - from ._models_py3 import EnvironmentDetails - from ._models_py3 import EnvironmentFragment - from ._models_py3 import EnvironmentOperationsPayload - from ._models_py3 import EnvironmentSetting - from ._models_py3 import EnvironmentSettingCreationParameters - from ._models_py3 import EnvironmentSettingFragment - from ._models_py3 import EnvironmentSize - from ._models_py3 import EnvironmentSizeFragment - from ._models_py3 import GalleryImage - from ._models_py3 import GalleryImageFragment - from ._models_py3 import GalleryImageReference - from ._models_py3 import GalleryImageReferenceFragment - from ._models_py3 import GetEnvironmentResponse - from ._models_py3 import GetPersonalPreferencesResponse - from ._models_py3 import GetRegionalAvailabilityResponse - from ._models_py3 import Lab - from ._models_py3 import LabAccount - from ._models_py3 import LabAccountFragment - from ._models_py3 import LabCreationParameters - from ._models_py3 import LabDetails - from ._models_py3 import LabFragment - from ._models_py3 import LatestOperationResult - from ._models_py3 import ListEnvironmentsPayload - from ._models_py3 import ListEnvironmentsResponse - from ._models_py3 import ListLabsResponse - from ._models_py3 import NetworkInterface - from ._models_py3 import OperationBatchStatusPayload - from ._models_py3 import OperationBatchStatusResponse - from ._models_py3 import OperationBatchStatusResponseItem - from ._models_py3 import OperationError - from ._models_py3 import OperationMetadata - from ._models_py3 import OperationMetadataDisplay - from ._models_py3 import OperationResult - from ._models_py3 import OperationStatusPayload - from ._models_py3 import OperationStatusResponse - from ._models_py3 import PersonalPreferencesOperationsPayload - from ._models_py3 import ProviderOperationResult - from ._models_py3 import PublishPayload - from ._models_py3 import ReferenceVm - from ._models_py3 import ReferenceVmCreationParameters - from ._models_py3 import ReferenceVmFragment - from ._models_py3 import RegionalAvailability - from ._models_py3 import RegisterPayload - from ._models_py3 import ResetPasswordPayload - from ._models_py3 import Resource - from ._models_py3 import ResourceSet - from ._models_py3 import ResourceSetFragment - from ._models_py3 import ResourceSettingCreationParameters - from ._models_py3 import ResourceSettings - from ._models_py3 import ResourceSettingsFragment - from ._models_py3 import ResponseWithContinuationEnvironment - from ._models_py3 import ResponseWithContinuationEnvironmentSetting - from ._models_py3 import ResponseWithContinuationGalleryImage - from ._models_py3 import ResponseWithContinuationLab - from ._models_py3 import ResponseWithContinuationLabAccount - from ._models_py3 import ResponseWithContinuationUser - from ._models_py3 import SizeAvailability - from ._models_py3 import SizeConfigurationProperties - from ._models_py3 import SizeConfigurationPropertiesFragment - from ._models_py3 import SizeInfo - from ._models_py3 import SizeInfoFragment - from ._models_py3 import User - from ._models_py3 import UserFragment - from ._models_py3 import VirtualMachineDetails - from ._models_py3 import VmStateDetails -except (SyntaxError, ImportError): - from ._models import AddUsersPayload # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import CreateLabProperties # type: ignore - from ._models import Environment # type: ignore - from ._models import EnvironmentDetails # type: ignore - from ._models import EnvironmentFragment # type: ignore - from ._models import EnvironmentOperationsPayload # type: ignore - from ._models import EnvironmentSetting # type: ignore - from ._models import EnvironmentSettingCreationParameters # type: ignore - from ._models import EnvironmentSettingFragment # type: ignore - from ._models import EnvironmentSize # type: ignore - from ._models import EnvironmentSizeFragment # type: ignore - from ._models import GalleryImage # type: ignore - from ._models import GalleryImageFragment # type: ignore - from ._models import GalleryImageReference # type: ignore - from ._models import GalleryImageReferenceFragment # type: ignore - from ._models import GetEnvironmentResponse # type: ignore - from ._models import GetPersonalPreferencesResponse # type: ignore - from ._models import GetRegionalAvailabilityResponse # type: ignore - from ._models import Lab # type: ignore - from ._models import LabAccount # type: ignore - from ._models import LabAccountFragment # type: ignore - from ._models import LabCreationParameters # type: ignore - from ._models import LabDetails # type: ignore - from ._models import LabFragment # type: ignore - from ._models import LatestOperationResult # type: ignore - from ._models import ListEnvironmentsPayload # type: ignore - from ._models import ListEnvironmentsResponse # type: ignore - from ._models import ListLabsResponse # type: ignore - from ._models import NetworkInterface # type: ignore - from ._models import OperationBatchStatusPayload # type: ignore - from ._models import OperationBatchStatusResponse # type: ignore - from ._models import OperationBatchStatusResponseItem # 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 OperationStatusPayload # type: ignore - from ._models import OperationStatusResponse # type: ignore - from ._models import PersonalPreferencesOperationsPayload # type: ignore - from ._models import ProviderOperationResult # type: ignore - from ._models import PublishPayload # type: ignore - from ._models import ReferenceVm # type: ignore - from ._models import ReferenceVmCreationParameters # type: ignore - from ._models import ReferenceVmFragment # type: ignore - from ._models import RegionalAvailability # type: ignore - from ._models import RegisterPayload # type: ignore - from ._models import ResetPasswordPayload # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceSet # type: ignore - from ._models import ResourceSetFragment # type: ignore - from ._models import ResourceSettingCreationParameters # type: ignore - from ._models import ResourceSettings # type: ignore - from ._models import ResourceSettingsFragment # type: ignore - from ._models import ResponseWithContinuationEnvironment # type: ignore - from ._models import ResponseWithContinuationEnvironmentSetting # type: ignore - from ._models import ResponseWithContinuationGalleryImage # type: ignore - from ._models import ResponseWithContinuationLab # type: ignore - from ._models import ResponseWithContinuationLabAccount # type: ignore - from ._models import ResponseWithContinuationUser # type: ignore - from ._models import SizeAvailability # type: ignore - from ._models import SizeConfigurationProperties # type: ignore - from ._models import SizeConfigurationPropertiesFragment # type: ignore - from ._models import SizeInfo # type: ignore - from ._models import SizeInfoFragment # type: ignore - from ._models import User # type: ignore - from ._models import UserFragment # type: ignore - from ._models import VirtualMachineDetails # type: ignore - from ._models import VmStateDetails # type: ignore +from ._models_py3 import AutoShutdownProfile +from ._models_py3 import ConnectionProfile +from ._models_py3 import Credentials +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Image +from ._models_py3 import ImageProperties +from ._models_py3 import ImageReference +from ._models_py3 import ImageUpdate +from ._models_py3 import ImageUpdateProperties +from ._models_py3 import InviteBody +from ._models_py3 import Lab +from ._models_py3 import LabNetworkProfile +from ._models_py3 import LabPlan +from ._models_py3 import LabPlanNetworkProfile +from ._models_py3 import LabPlanProperties +from ._models_py3 import LabPlanUpdate +from ._models_py3 import LabPlanUpdateProperties +from ._models_py3 import LabProperties +from ._models_py3 import LabServicesSku +from ._models_py3 import LabServicesSkuCapabilities +from ._models_py3 import LabServicesSkuCapacity +from ._models_py3 import LabServicesSkuCost +from ._models_py3 import LabServicesSkuRestrictions +from ._models_py3 import LabUpdate +from ._models_py3 import LabUpdateProperties +from ._models_py3 import ListUsagesResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OperationResult +from ._models_py3 import PagedImages +from ._models_py3 import PagedLabPlans +from ._models_py3 import PagedLabServicesSkus +from ._models_py3 import PagedLabs +from ._models_py3 import PagedSchedules +from ._models_py3 import PagedUsers +from ._models_py3 import PagedVirtualMachines +from ._models_py3 import ProxyResource +from ._models_py3 import RecurrencePattern +from ._models_py3 import ResetPasswordBody +from ._models_py3 import Resource +from ._models_py3 import RosterProfile +from ._models_py3 import SaveImageBody +from ._models_py3 import Schedule +from ._models_py3 import ScheduleProperties +from ._models_py3 import ScheduleUpdate +from ._models_py3 import ScheduleUpdateProperties +from ._models_py3 import SecurityProfile +from ._models_py3 import Sku +from ._models_py3 import SupportInfo +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import TrackedResourceUpdate +from ._models_py3 import Usage +from ._models_py3 import UsageName +from ._models_py3 import User +from ._models_py3 import UserProperties +from ._models_py3 import UserUpdate +from ._models_py3 import UserUpdateProperties +from ._models_py3 import VirtualMachine +from ._models_py3 import VirtualMachineAdditionalCapabilities +from ._models_py3 import VirtualMachineConnectionProfile +from ._models_py3 import VirtualMachineProfile -from ._managed_labs_client_enums import ( - AddRemove, - ConfigurationState, - LabUserAccessMode, - ManagedLabVmSize, - PublishingState, + +from ._lab_services_client_enums import ( + ActionType, + ConnectionType, + CreateOption, + CreatedByType, + EnableState, + InvitationState, + LabServicesSkuTier, + LabState, + OperationStatus, + Origin, + OsState, + OsType, + ProvisioningState, + RecurrenceFrequency, + RegistrationState, + RestrictionReasonCode, + RestrictionType, + ScaleType, + ShutdownOnIdleMode, + SkuTier, + UsageUnit, + VirtualMachineState, + VirtualMachineType, + WeekDay, ) __all__ = [ - 'AddUsersPayload', - 'CloudErrorBody', - 'CreateLabProperties', - 'Environment', - 'EnvironmentDetails', - 'EnvironmentFragment', - 'EnvironmentOperationsPayload', - 'EnvironmentSetting', - 'EnvironmentSettingCreationParameters', - 'EnvironmentSettingFragment', - 'EnvironmentSize', - 'EnvironmentSizeFragment', - 'GalleryImage', - 'GalleryImageFragment', - 'GalleryImageReference', - 'GalleryImageReferenceFragment', - 'GetEnvironmentResponse', - 'GetPersonalPreferencesResponse', - 'GetRegionalAvailabilityResponse', + 'AutoShutdownProfile', + 'ConnectionProfile', + 'Credentials', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'Image', + 'ImageProperties', + 'ImageReference', + 'ImageUpdate', + 'ImageUpdateProperties', + 'InviteBody', 'Lab', - 'LabAccount', - 'LabAccountFragment', - 'LabCreationParameters', - 'LabDetails', - 'LabFragment', - 'LatestOperationResult', - 'ListEnvironmentsPayload', - 'ListEnvironmentsResponse', - 'ListLabsResponse', - 'NetworkInterface', - 'OperationBatchStatusPayload', - 'OperationBatchStatusResponse', - 'OperationBatchStatusResponseItem', - 'OperationError', - 'OperationMetadata', - 'OperationMetadataDisplay', + 'LabNetworkProfile', + 'LabPlan', + 'LabPlanNetworkProfile', + 'LabPlanProperties', + 'LabPlanUpdate', + 'LabPlanUpdateProperties', + 'LabProperties', + 'LabServicesSku', + 'LabServicesSkuCapabilities', + 'LabServicesSkuCapacity', + 'LabServicesSkuCost', + 'LabServicesSkuRestrictions', + 'LabUpdate', + 'LabUpdateProperties', + 'ListUsagesResult', + 'Operation', + 'OperationDisplay', + 'OperationListResult', 'OperationResult', - 'OperationStatusPayload', - 'OperationStatusResponse', - 'PersonalPreferencesOperationsPayload', - 'ProviderOperationResult', - 'PublishPayload', - 'ReferenceVm', - 'ReferenceVmCreationParameters', - 'ReferenceVmFragment', - 'RegionalAvailability', - 'RegisterPayload', - 'ResetPasswordPayload', + 'PagedImages', + 'PagedLabPlans', + 'PagedLabServicesSkus', + 'PagedLabs', + 'PagedSchedules', + 'PagedUsers', + 'PagedVirtualMachines', + 'ProxyResource', + 'RecurrencePattern', + 'ResetPasswordBody', 'Resource', - 'ResourceSet', - 'ResourceSetFragment', - 'ResourceSettingCreationParameters', - 'ResourceSettings', - 'ResourceSettingsFragment', - 'ResponseWithContinuationEnvironment', - 'ResponseWithContinuationEnvironmentSetting', - 'ResponseWithContinuationGalleryImage', - 'ResponseWithContinuationLab', - 'ResponseWithContinuationLabAccount', - 'ResponseWithContinuationUser', - 'SizeAvailability', - 'SizeConfigurationProperties', - 'SizeConfigurationPropertiesFragment', - 'SizeInfo', - 'SizeInfoFragment', + 'RosterProfile', + 'SaveImageBody', + 'Schedule', + 'ScheduleProperties', + 'ScheduleUpdate', + 'ScheduleUpdateProperties', + 'SecurityProfile', + 'Sku', + 'SupportInfo', + 'SystemData', + 'TrackedResource', + 'TrackedResourceUpdate', + 'Usage', + 'UsageName', 'User', - 'UserFragment', - 'VirtualMachineDetails', - 'VmStateDetails', - 'AddRemove', - 'ConfigurationState', - 'LabUserAccessMode', - 'ManagedLabVmSize', - 'PublishingState', + 'UserProperties', + 'UserUpdate', + 'UserUpdateProperties', + 'VirtualMachine', + 'VirtualMachineAdditionalCapabilities', + 'VirtualMachineConnectionProfile', + 'VirtualMachineProfile', + 'ActionType', + 'ConnectionType', + 'CreateOption', + 'CreatedByType', + 'EnableState', + 'InvitationState', + 'LabServicesSkuTier', + 'LabState', + 'OperationStatus', + 'Origin', + 'OsState', + 'OsType', + 'ProvisioningState', + 'RecurrenceFrequency', + 'RegistrationState', + 'RestrictionReasonCode', + 'RestrictionType', + 'ScaleType', + 'ShutdownOnIdleMode', + 'SkuTier', + 'UsageUnit', + 'VirtualMachineState', + 'VirtualMachineType', + 'WeekDay', ] diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_lab_services_client_enums.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_lab_services_client_enums.py new file mode 100644 index 000000000000..7353dc17965d --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_lab_services_client_enums.py @@ -0,0 +1,263 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class ConnectionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """A connection type for access labs and VMs (Public, Private or None). + """ + + PUBLIC = "Public" + PRIVATE = "Private" + NONE = "None" + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class CreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Indicates what lab virtual machines are created from. + """ + + #: An image is used to create all lab user virtual machines. When this option is set, no template + #: VM will be created. + IMAGE = "Image" + #: A template VM will be used to create all lab user virtual machines. + TEMPLATE_VM = "TemplateVM" + +class EnableState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Property enabled state. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + +class InvitationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The lab user invitation state. + """ + + #: The invitation has not been sent. + NOT_SENT = "NotSent" + #: Currently sending the invitation. + SENDING = "Sending" + #: The invitation has been successfully sent. + SENT = "Sent" + #: There was an error while sending the invitation. + FAILED = "Failed" + +class LabServicesSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The tier of the SKU. + """ + + STANDARD = "Standard" + PREMIUM = "Premium" + +class LabState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The state of a virtual machine. + """ + + #: The lab is currently in draft (has not been published). + DRAFT = "Draft" + #: The lab is publishing. + PUBLISHING = "Publishing" + #: The lab is scaling. + SCALING = "Scaling" + #: The lab is syncing users. + SYNCING = "Syncing" + #: The lab has been published. + PUBLISHED = "Published" + +class OperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The operation status + """ + + #: The operation has been accepted but hasn't started. + NOT_STARTED = "NotStarted" + #: The operation is running. + IN_PROGRESS = "InProgress" + #: The operation Succeeded. + SUCCEEDED = "Succeeded" + #: The operation failed. + FAILED = "Failed" + #: Not supported yet. + CANCELED = "Canceled" + +class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class OsState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The operating system state. + """ + + #: Image does not contain any machine and user specific information. + GENERALIZED = "Generalized" + #: Image contains machine and user specific information. + SPECIALIZED = "Specialized" + +class OsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The operating system type. + """ + + WINDOWS = "Windows" + LINUX = "Linux" + +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Resource provisioning state. + """ + + #: Resource is in the process of being created. + CREATING = "Creating" + #: New property values are being applied to the resource. + UPDATING = "Updating" + #: Resource is in the process of being deleted. + DELETING = "Deleting" + #: Resource is in healthy state after creation or update operation. + SUCCEEDED = "Succeeded" + #: Previous operation on the resource has failed leaving resource in unhealthy state. + FAILED = "Failed" + #: The resource is locked and changes are currently blocked. This could be due to maintenance or a + #: scheduled operation. The state will go back to succeeded once the locking operation has + #: finished. + LOCKED = "Locked" + +class RecurrenceFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Schedule recurrence frequencies. + """ + + #: Schedule will run every days. + DAILY = "Daily" + #: Schedule will run every week on days specified in weekDays. + WEEKLY = "Weekly" + +class RegistrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The user lab registration state. + """ + + #: User has not yet registered with the lab. + REGISTERED = "Registered" + #: User has registered with the lab. + NOT_REGISTERED = "NotRegistered" + +class RestrictionReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The reason for the restriction. + """ + + QUOTA_ID = "QuotaId" + NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + +class RestrictionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of restriction. + """ + + LOCATION = "Location" + +class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The localized name of the resource. + """ + + #: The capacity is not adjustable in any way. + NONE = "None" + #: The user must manually scale this SKU in and out. + MANUAL = "Manual" + #: The user is permitted to scale this SKU in and out. + AUTOMATIC = "Automatic" + +class ShutdownOnIdleMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Defines whether to shut down VM on idle and the criteria for idle detection. + """ + + #: The VM won't be shut down when it is idle. + NONE = "None" + #: The VM will be considered as idle when there is no keyboard or mouse input. + USER_ABSENCE = "UserAbsence" + #: The VM will be considered as idle when user is absent and the resource (CPU and disk) + #: consumption is low. + LOW_USAGE = "LowUsage" + +class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """This field is required to be implemented by the Resource Provider if the service has more than + one tier, but is not required on a PUT. + """ + + FREE = "Free" + BASIC = "Basic" + STANDARD = "Standard" + PREMIUM = "Premium" + +class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The unit details. + """ + + COUNT = "Count" + +class VirtualMachineState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The state of a virtual machine. + """ + + #: The VM is currently stopped. + STOPPED = "Stopped" + #: The VM is starting. + STARTING = "Starting" + #: The VM is running. + RUNNING = "Running" + #: The VM is stopping. + STOPPING = "Stopping" + #: The VM password is being reset. + RESETTING_PASSWORD = "ResettingPassword" + #: The VM is being reimaged. + REIMAGING = "Reimaging" + #: The VM is being redeployed. + REDEPLOYING = "Redeploying" + +class VirtualMachineType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of the lab virtual machine. + """ + + #: A user VM. + USER = "User" + #: A template VM. + TEMPLATE = "Template" + +class WeekDay(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Days of the week. + """ + + #: Schedule will run on Sunday. + SUNDAY = "Sunday" + #: Schedule will run on Monday. + MONDAY = "Monday" + #: Schedule will run on Tuesday. + TUESDAY = "Tuesday" + #: Schedule will run on Wednesday. + WEDNESDAY = "Wednesday" + #: Schedule will run on Thursday. + THURSDAY = "Thursday" + #: Schedule will run on Friday. + FRIDAY = "Friday" + #: Schedule will run on Saturday. + SATURDAY = "Saturday" diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_managed_labs_client_enums.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_managed_labs_client_enums.py deleted file mode 100644 index 54fd195d6171..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_managed_labs_client_enums.py +++ /dev/null @@ -1,81 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AddRemove(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Enum indicating if user is adding or removing a favorite lab - """ - - #: Indicates that a user is adding a favorite lab. - ADD = "Add" - #: Indicates that a user is removing a favorite lab. - REMOVE = "Remove" - -class ConfigurationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Describes the user's progress in configuring their environment setting - """ - - #: User either hasn't started configuring their template - #: or they haven't started the configuration process. - NOT_APPLICABLE = "NotApplicable" - #: User is finished modifying the template. - COMPLETED = "Completed" - -class LabUserAccessMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Lab user access mode (open to all vs. restricted to those listed on the lab). - """ - - #: Only users registered with the lab can access VMs. - RESTRICTED = "Restricted" - #: Any user can register with the lab and access its VMs. - OPEN = "Open" - -class ManagedLabVmSize(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The size category - """ - - #: The base VM size. - BASIC = "Basic" - #: The standard or default VM size. - STANDARD = "Standard" - #: The most performant VM size. - PERFORMANCE = "Performance" - -class PublishingState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Describes the readiness of this environment setting - """ - - #: Initial state of an environment setting. - DRAFT = "Draft" - #: Currently provisioning resources. - PUBLISHING = "Publishing" - #: All resources are currently provisioned. - PUBLISHED = "Published" - #: Failed to provision all the necessary resources. - PUBLISH_FAILED = "PublishFailed" - #: Currently provisioning resources without recreating VM image. - SCALING = "Scaling" diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_models.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_models.py deleted file mode 100644 index b7717686ab1a..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_models.py +++ /dev/null @@ -1,2516 +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 AddUsersPayload(msrest.serialization.Model): - """Payload for Add Users operation on a Lab. - - All required parameters must be populated in order to send to Azure. - - :param email_addresses: Required. List of user emails addresses to add to the lab. - :type email_addresses: list[str] - """ - - _validation = { - 'email_addresses': {'required': True}, - } - - _attribute_map = { - 'email_addresses': {'key': 'emailAddresses', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(AddUsersPayload, self).__init__(**kwargs) - self.email_addresses = kwargs['email_addresses'] - - -class CloudErrorBody(msrest.serialization.Model): - """Body of an error from a REST request. - - :param code: - :type code: str - :param message: - :type message: str - :param target: - :type target: str - :param details: Inner errors. - :type details: list[~azure.mgmt.labservices.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 CreateLabProperties(msrest.serialization.Model): - """Properties for creating a managed lab and a default environment setting. - - All required parameters must be populated in order to send to Azure. - - :param environment_setting_creation_parameters: Settings related to creating an environment - setting. - :type environment_setting_creation_parameters: - ~azure.mgmt.labservices.models.EnvironmentSettingCreationParameters - :param lab_creation_parameters: Required. Settings related to creating a lab. - :type lab_creation_parameters: ~azure.mgmt.labservices.models.LabCreationParameters - :param name: Required. The name of the resource. - :type name: 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 = { - 'lab_creation_parameters': {'required': True}, - 'name': {'required': True}, - } - - _attribute_map = { - 'environment_setting_creation_parameters': {'key': 'environmentSettingCreationParameters', 'type': 'EnvironmentSettingCreationParameters'}, - 'lab_creation_parameters': {'key': 'labCreationParameters', 'type': 'LabCreationParameters'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateLabProperties, self).__init__(**kwargs) - self.environment_setting_creation_parameters = kwargs.get('environment_setting_creation_parameters', None) - self.lab_creation_parameters = kwargs['lab_creation_parameters'] - self.name = kwargs['name'] - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -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 Environment(Resource): - """Represents an environment instance. - - 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 resource_sets: The set of a VM and the setting id it was created for. - :type resource_sets: ~azure.mgmt.labservices.models.ResourceSet - :ivar claimed_by_user_object_id: The AAD object Id of the user who has claimed the environment. - :vartype claimed_by_user_object_id: str - :ivar claimed_by_user_principal_id: The user principal Id of the user who has claimed the - environment. - :vartype claimed_by_user_principal_id: str - :ivar claimed_by_user_name: The name or email address of the user who has claimed the - environment. - :vartype claimed_by_user_name: str - :ivar is_claimed: Is the environment claimed or not. - :vartype is_claimed: bool - :ivar last_known_power_state: Last known power state of the environment. - :vartype last_known_power_state: str - :ivar network_interface: Network details of the environment. - :vartype network_interface: ~azure.mgmt.labservices.models.NetworkInterface - :ivar total_usage: How long the environment has been used by a lab user. - :vartype total_usage: ~datetime.timedelta - :ivar password_last_reset: When the password was last reset on the environment. - :vartype password_last_reset: ~datetime.datetime - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'claimed_by_user_object_id': {'readonly': True}, - 'claimed_by_user_principal_id': {'readonly': True}, - 'claimed_by_user_name': {'readonly': True}, - 'is_claimed': {'readonly': True}, - 'last_known_power_state': {'readonly': True}, - 'network_interface': {'readonly': True}, - 'total_usage': {'readonly': True}, - 'password_last_reset': {'readonly': True}, - 'latest_operation_result': {'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}'}, - 'resource_sets': {'key': 'properties.resourceSets', 'type': 'ResourceSet'}, - 'claimed_by_user_object_id': {'key': 'properties.claimedByUserObjectId', 'type': 'str'}, - 'claimed_by_user_principal_id': {'key': 'properties.claimedByUserPrincipalId', 'type': 'str'}, - 'claimed_by_user_name': {'key': 'properties.claimedByUserName', 'type': 'str'}, - 'is_claimed': {'key': 'properties.isClaimed', 'type': 'bool'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterface'}, - 'total_usage': {'key': 'properties.totalUsage', 'type': 'duration'}, - 'password_last_reset': {'key': 'properties.passwordLastReset', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, - } - - def __init__( - self, - **kwargs - ): - super(Environment, self).__init__(**kwargs) - self.resource_sets = kwargs.get('resource_sets', None) - self.claimed_by_user_object_id = None - self.claimed_by_user_principal_id = None - self.claimed_by_user_name = None - self.is_claimed = None - self.last_known_power_state = None - self.network_interface = None - self.total_usage = None - self.password_last_reset = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - self.latest_operation_result = None - - -class EnvironmentDetails(msrest.serialization.Model): - """This represents the details about a User's environment and its state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the Environment. - :vartype name: str - :ivar description: Description of the Environment. - :vartype description: str - :ivar id: Resource Id of the environment. - :vartype id: str - :ivar provisioning_state: The provisioning state of the environment. This also includes - LabIsFull and NotYetProvisioned status. - :vartype provisioning_state: str - :ivar virtual_machine_details: Details of backing DTL virtual machine with compute and network - details. - :vartype virtual_machine_details: ~azure.mgmt.labservices.models.VirtualMachineDetails - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - :ivar environment_state: Publishing state of the environment setting Possible values are - Creating, Created, Failed. - :vartype environment_state: str - :ivar total_usage: How long the environment has been used by a lab user. - :vartype total_usage: ~datetime.timedelta - :ivar password_last_reset: When the password was last reset on the environment. - :vartype password_last_reset: ~datetime.datetime - """ - - _validation = { - 'name': {'readonly': True}, - 'description': {'readonly': True}, - 'id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'virtual_machine_details': {'readonly': True}, - 'latest_operation_result': {'readonly': True}, - 'environment_state': {'readonly': True}, - 'total_usage': {'readonly': True}, - 'password_last_reset': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'virtual_machine_details': {'key': 'virtualMachineDetails', 'type': 'VirtualMachineDetails'}, - 'latest_operation_result': {'key': 'latestOperationResult', 'type': 'LatestOperationResult'}, - 'environment_state': {'key': 'environmentState', 'type': 'str'}, - 'total_usage': {'key': 'totalUsage', 'type': 'duration'}, - 'password_last_reset': {'key': 'passwordLastReset', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentDetails, self).__init__(**kwargs) - self.name = None - self.description = None - self.id = None - self.provisioning_state = None - self.virtual_machine_details = None - self.latest_operation_result = None - self.environment_state = None - self.total_usage = None - self.password_last_reset = None - - -class EnvironmentFragment(Resource): - """Represents an environment instance. - - 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 resource_sets: The set of a VM and the setting id it was created for. - :type resource_sets: ~azure.mgmt.labservices.models.ResourceSetFragment - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: 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}'}, - 'resource_sets': {'key': 'properties.resourceSets', 'type': 'ResourceSetFragment'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentFragment, self).__init__(**kwargs) - self.resource_sets = kwargs.get('resource_sets', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - - -class EnvironmentOperationsPayload(msrest.serialization.Model): - """Represents payload for any Environment operations like get, start, stop, connect. - - All required parameters must be populated in order to send to Azure. - - :param environment_id: Required. The resourceId of the environment. - :type environment_id: str - """ - - _validation = { - 'environment_id': {'required': True}, - } - - _attribute_map = { - 'environment_id': {'key': 'environmentId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentOperationsPayload, self).__init__(**kwargs) - self.environment_id = kwargs['environment_id'] - - -class EnvironmentSetting(Resource): - """Represents settings of an environment, from which environment instances would be created. - - 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 publishing_state: Describes the readiness of this environment setting. Possible values - include: "Draft", "Publishing", "Published", "PublishFailed", "Scaling". - :vartype publishing_state: str or ~azure.mgmt.labservices.models.PublishingState - :param configuration_state: Describes the user's progress in configuring their environment - setting. Possible values include: "NotApplicable", "Completed". - :type configuration_state: str or ~azure.mgmt.labservices.models.ConfigurationState - :param description: Describes the environment and its resource settings. - :type description: str - :param title: Brief title describing the environment and its resource settings. - :type title: str - :param resource_settings: The resource specific settings. - :type resource_settings: ~azure.mgmt.labservices.models.ResourceSettings - :ivar last_changed: Time when the template VM was last changed. - :vartype last_changed: ~datetime.datetime - :ivar last_published: Time when the template VM was last sent for publishing. - :vartype last_published: ~datetime.datetime - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'publishing_state': {'readonly': True}, - 'last_changed': {'readonly': True}, - 'last_published': {'readonly': True}, - 'latest_operation_result': {'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}'}, - 'publishing_state': {'key': 'properties.publishingState', 'type': 'str'}, - 'configuration_state': {'key': 'properties.configurationState', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'resource_settings': {'key': 'properties.resourceSettings', 'type': 'ResourceSettings'}, - 'last_changed': {'key': 'properties.lastChanged', 'type': 'iso-8601'}, - 'last_published': {'key': 'properties.lastPublished', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentSetting, self).__init__(**kwargs) - self.publishing_state = None - self.configuration_state = kwargs.get('configuration_state', None) - self.description = kwargs.get('description', None) - self.title = kwargs.get('title', None) - self.resource_settings = kwargs.get('resource_settings', None) - self.last_changed = None - self.last_published = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - self.latest_operation_result = None - - -class EnvironmentSettingCreationParameters(msrest.serialization.Model): - """Settings related to creating an environment setting. - - All required parameters must be populated in order to send to Azure. - - :param resource_setting_creation_parameters: Required. The resource specific settings. - :type resource_setting_creation_parameters: - ~azure.mgmt.labservices.models.ResourceSettingCreationParameters - """ - - _validation = { - 'resource_setting_creation_parameters': {'required': True}, - } - - _attribute_map = { - 'resource_setting_creation_parameters': {'key': 'resourceSettingCreationParameters', 'type': 'ResourceSettingCreationParameters'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentSettingCreationParameters, self).__init__(**kwargs) - self.resource_setting_creation_parameters = kwargs['resource_setting_creation_parameters'] - - -class EnvironmentSettingFragment(Resource): - """Represents settings of an environment, from which environment instances would be created. - - 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 configuration_state: Describes the user's progress in configuring their environment - setting. Possible values include: "NotApplicable", "Completed". - :type configuration_state: str or ~azure.mgmt.labservices.models.ConfigurationState - :param description: Describes the environment and its resource settings. - :type description: str - :param title: Brief title describing the environment and its resource settings. - :type title: str - :param resource_settings: The resource specific settings. - :type resource_settings: ~azure.mgmt.labservices.models.ResourceSettingsFragment - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: 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}'}, - 'configuration_state': {'key': 'properties.configurationState', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'resource_settings': {'key': 'properties.resourceSettings', 'type': 'ResourceSettingsFragment'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentSettingFragment, self).__init__(**kwargs) - self.configuration_state = kwargs.get('configuration_state', None) - self.description = kwargs.get('description', None) - self.title = kwargs.get('title', None) - self.resource_settings = kwargs.get('resource_settings', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - - -class EnvironmentSize(msrest.serialization.Model): - """Represents a size category supported by this Lab Account (small, medium or large). - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: The size category. Possible values include: "Basic", "Standard", "Performance". - :type name: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param vm_sizes: Represents a set of compute sizes that can serve this given size type. - :type vm_sizes: list[~azure.mgmt.labservices.models.SizeInfo] - :ivar max_price: The pay-as-you-go dollar price per hour this size will cost. It does not - include discounts and may not reflect the actual price the size will cost. This is the maximum - price of all prices within this tier. - :vartype max_price: float - :ivar min_number_of_cores: The number of cores a VM of this size has. This is the minimum - number of cores within this tier. - :vartype min_number_of_cores: int - :ivar min_memory: The amount of memory available (in GB). This is the minimum amount of memory - within this tier. - :vartype min_memory: float - """ - - _validation = { - 'max_price': {'readonly': True}, - 'min_number_of_cores': {'readonly': True}, - 'min_memory': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'vm_sizes': {'key': 'vmSizes', 'type': '[SizeInfo]'}, - 'max_price': {'key': 'maxPrice', 'type': 'float'}, - 'min_number_of_cores': {'key': 'minNumberOfCores', 'type': 'int'}, - 'min_memory': {'key': 'minMemory', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentSize, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.vm_sizes = kwargs.get('vm_sizes', None) - self.max_price = None - self.min_number_of_cores = None - self.min_memory = None - - -class EnvironmentSizeFragment(msrest.serialization.Model): - """Represents a size category supported by this Lab Account (small, medium or large). - - :param name: The size category. Possible values include: "Basic", "Standard", "Performance". - :type name: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param vm_sizes: Represents a set of compute sizes that can serve this given size type. - :type vm_sizes: list[~azure.mgmt.labservices.models.SizeInfoFragment] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'vm_sizes': {'key': 'vmSizes', 'type': '[SizeInfoFragment]'}, - } - - def __init__( - self, - **kwargs - ): - super(EnvironmentSizeFragment, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.vm_sizes = kwargs.get('vm_sizes', None) - - -class GalleryImage(Resource): - """Represents an image from the Azure Marketplace. - - 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 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 - :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.labservices.models.GalleryImageReference - :ivar icon: The icon of the gallery image. - :vartype icon: str - :param is_enabled: Indicates whether this gallery image is enabled. - :type is_enabled: bool - :param is_override: Indicates whether this gallery has been overridden for this lab account. - :type is_override: bool - :ivar plan_id: The third party plan that applies to this image. - :vartype plan_id: str - :param is_plan_authorized: Indicates if the plan has been authorized for programmatic - deployment. - :type is_plan_authorized: bool - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'author': {'readonly': True}, - 'created_date': {'readonly': True}, - 'description': {'readonly': True}, - 'image_reference': {'readonly': True}, - 'icon': {'readonly': True}, - 'plan_id': {'readonly': True}, - 'latest_operation_result': {'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'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'is_override': {'key': 'properties.isOverride', 'type': 'bool'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'is_plan_authorized': {'key': 'properties.isPlanAuthorized', 'type': 'bool'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, - } - - def __init__( - self, - **kwargs - ): - super(GalleryImage, self).__init__(**kwargs) - self.author = None - self.created_date = None - self.description = None - self.image_reference = None - self.icon = None - self.is_enabled = kwargs.get('is_enabled', None) - self.is_override = kwargs.get('is_override', None) - self.plan_id = None - self.is_plan_authorized = kwargs.get('is_plan_authorized', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - self.latest_operation_result = None - - -class GalleryImageFragment(Resource): - """Represents an image from the Azure Marketplace. - - 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 is_enabled: Indicates whether this gallery image is enabled. - :type is_enabled: bool - :param is_override: Indicates whether this gallery has been overridden for this lab account. - :type is_override: bool - :param is_plan_authorized: Indicates if the plan has been authorized for programmatic - deployment. - :type is_plan_authorized: bool - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: 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}'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'is_override': {'key': 'properties.isOverride', 'type': 'bool'}, - '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(GalleryImageFragment, self).__init__(**kwargs) - self.is_enabled = kwargs.get('is_enabled', None) - self.is_override = kwargs.get('is_override', None) - self.is_plan_authorized = kwargs.get('is_plan_authorized', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', 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 GetEnvironmentResponse(msrest.serialization.Model): - """Represents the environments details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar environment: Details of the environment. - :vartype environment: ~azure.mgmt.labservices.models.EnvironmentDetails - """ - - _validation = { - 'environment': {'readonly': True}, - } - - _attribute_map = { - 'environment': {'key': 'environment', 'type': 'EnvironmentDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(GetEnvironmentResponse, self).__init__(**kwargs) - self.environment = None - - -class GetPersonalPreferencesResponse(msrest.serialization.Model): - """Represents the PersonalPreferences for the user. - - :param id: Id to be used by the cache orchestrator. - :type id: str - :param favorite_lab_resource_ids: Array of favorite lab resource ids. - :type favorite_lab_resource_ids: list[str] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'favorite_lab_resource_ids': {'key': 'favoriteLabResourceIds', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(GetPersonalPreferencesResponse, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.favorite_lab_resource_ids = kwargs.get('favorite_lab_resource_ids', None) - - -class GetRegionalAvailabilityResponse(msrest.serialization.Model): - """The response model from the GetRegionalAvailability action. - - :param regional_availability: Availability information for different size categories per - region. - :type regional_availability: list[~azure.mgmt.labservices.models.RegionalAvailability] - """ - - _attribute_map = { - 'regional_availability': {'key': 'regionalAvailability', 'type': '[RegionalAvailability]'}, - } - - def __init__( - self, - **kwargs - ): - super(GetRegionalAvailabilityResponse, self).__init__(**kwargs) - self.regional_availability = kwargs.get('regional_availability', None) - - -class Lab(Resource): - """Represents 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] - :param max_users_in_lab: Maximum number of users allowed in the lab. - :type max_users_in_lab: int - :ivar user_quota: Maximum value MaxUsersInLab can be set to, as specified by the service. - :vartype user_quota: int - :ivar invitation_code: Invitation code that users can use to join a lab. - :vartype invitation_code: str - :ivar created_by_object_id: Object id of the user that created the lab. - :vartype created_by_object_id: str - :param usage_quota: Maximum duration a user can use an environment for in the lab. - :type usage_quota: ~datetime.timedelta - :param user_access_mode: Lab user access mode (open to all vs. restricted to those listed on - the lab). Possible values include: "Restricted", "Open". - :type user_access_mode: str or ~azure.mgmt.labservices.models.LabUserAccessMode - :ivar created_by_user_principal_name: Lab creator name. - :vartype created_by_user_principal_name: str - :ivar created_date: Creation date for the lab. - :vartype created_date: ~datetime.datetime - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'user_quota': {'readonly': True}, - 'invitation_code': {'readonly': True}, - 'created_by_object_id': {'readonly': True}, - 'created_by_user_principal_name': {'readonly': True}, - 'created_date': {'readonly': True}, - 'latest_operation_result': {'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}'}, - 'max_users_in_lab': {'key': 'properties.maxUsersInLab', 'type': 'int'}, - 'user_quota': {'key': 'properties.userQuota', 'type': 'int'}, - 'invitation_code': {'key': 'properties.invitationCode', 'type': 'str'}, - 'created_by_object_id': {'key': 'properties.createdByObjectId', 'type': 'str'}, - 'usage_quota': {'key': 'properties.usageQuota', 'type': 'duration'}, - 'user_access_mode': {'key': 'properties.userAccessMode', 'type': 'str'}, - 'created_by_user_principal_name': {'key': 'properties.createdByUserPrincipalName', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, - } - - def __init__( - self, - **kwargs - ): - super(Lab, self).__init__(**kwargs) - self.max_users_in_lab = kwargs.get('max_users_in_lab', None) - self.user_quota = None - self.invitation_code = None - self.created_by_object_id = None - self.usage_quota = kwargs.get('usage_quota', None) - self.user_access_mode = kwargs.get('user_access_mode', None) - self.created_by_user_principal_name = None - self.created_date = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - self.latest_operation_result = None - - -class LabAccount(Resource): - """Represents a lab account. - - 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 size_configuration: Represents the size configuration under the lab account. - :vartype size_configuration: ~azure.mgmt.labservices.models.SizeConfigurationProperties - :param enabled_region_selection: Represents if region selection is enabled. - :type enabled_region_selection: bool - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'size_configuration': {'readonly': True}, - 'latest_operation_result': {'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}'}, - 'size_configuration': {'key': 'properties.sizeConfiguration', 'type': 'SizeConfigurationProperties'}, - 'enabled_region_selection': {'key': 'properties.enabledRegionSelection', 'type': 'bool'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, - } - - def __init__( - self, - **kwargs - ): - super(LabAccount, self).__init__(**kwargs) - self.size_configuration = None - self.enabled_region_selection = kwargs.get('enabled_region_selection', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - self.latest_operation_result = None - - -class LabAccountFragment(Resource): - """Represents a lab account. - - 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 enabled_region_selection: Represents if region selection is enabled. - :type enabled_region_selection: bool - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: 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}'}, - 'enabled_region_selection': {'key': 'properties.enabledRegionSelection', 'type': 'bool'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabAccountFragment, self).__init__(**kwargs) - self.enabled_region_selection = kwargs.get('enabled_region_selection', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - - -class LabCreationParameters(msrest.serialization.Model): - """Settings related to creating a lab. - - :param max_users_in_lab: Maximum number of users allowed in the lab. - :type max_users_in_lab: int - """ - - _attribute_map = { - 'max_users_in_lab': {'key': 'maxUsersInLab', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(LabCreationParameters, self).__init__(**kwargs) - self.max_users_in_lab = kwargs.get('max_users_in_lab', None) - - -class LabDetails(msrest.serialization.Model): - """This represents the details about a lab that the User is in, and its state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: Name of the lab. - :type name: str - :param provisioning_state: The provisioning state of the lab. - :type provisioning_state: str - :param id: The Id of the lab. - :type id: str - :ivar usage_quota: The maximum duration a user can use a VM in this lab. - :vartype usage_quota: ~datetime.timedelta - """ - - _validation = { - 'usage_quota': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'usage_quota': {'key': 'usageQuota', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(LabDetails, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.id = kwargs.get('id', None) - self.usage_quota = None - - -class LabFragment(Resource): - """Represents 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] - :param max_users_in_lab: Maximum number of users allowed in the lab. - :type max_users_in_lab: int - :param usage_quota: Maximum duration a user can use an environment for in the lab. - :type usage_quota: ~datetime.timedelta - :param user_access_mode: Lab user access mode (open to all vs. restricted to those listed on - the lab). Possible values include: "Restricted", "Open". - :type user_access_mode: str or ~azure.mgmt.labservices.models.LabUserAccessMode - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: 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}'}, - 'max_users_in_lab': {'key': 'properties.maxUsersInLab', 'type': 'int'}, - 'usage_quota': {'key': 'properties.usageQuota', 'type': 'duration'}, - 'user_access_mode': {'key': 'properties.userAccessMode', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LabFragment, self).__init__(**kwargs) - self.max_users_in_lab = kwargs.get('max_users_in_lab', None) - self.usage_quota = kwargs.get('usage_quota', None) - self.user_access_mode = kwargs.get('user_access_mode', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - - -class LatestOperationResult(msrest.serialization.Model): - """Details of the status of an operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The current status of the operation. - :vartype status: str - :ivar error_code: Error code on failure. - :vartype error_code: str - :ivar error_message: The error message. - :vartype error_message: str - :ivar request_uri: Request URI of the operation. - :vartype request_uri: str - :ivar http_method: The HttpMethod - PUT/POST/DELETE for the operation. - :vartype http_method: str - :ivar operation_url: The URL to use to check long-running operation status. - :vartype operation_url: str - """ - - _validation = { - 'status': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'request_uri': {'readonly': True}, - 'http_method': {'readonly': True}, - 'operation_url': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'http_method': {'key': 'httpMethod', 'type': 'str'}, - 'operation_url': {'key': 'operationUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LatestOperationResult, self).__init__(**kwargs) - self.status = None - self.error_code = None - self.error_message = None - self.request_uri = None - self.http_method = None - self.operation_url = None - - -class ListEnvironmentsPayload(msrest.serialization.Model): - """Represents the payload to list environments owned by a user. - - :param lab_id: The resource Id of the lab. - :type lab_id: str - """ - - _attribute_map = { - 'lab_id': {'key': 'labId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ListEnvironmentsPayload, self).__init__(**kwargs) - self.lab_id = kwargs.get('lab_id', None) - - -class ListEnvironmentsResponse(msrest.serialization.Model): - """Represents the list of environments owned by a user. - - :param environments: List of all the environments. - :type environments: list[~azure.mgmt.labservices.models.EnvironmentDetails] - """ - - _attribute_map = { - 'environments': {'key': 'environments', 'type': '[EnvironmentDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(ListEnvironmentsResponse, self).__init__(**kwargs) - self.environments = kwargs.get('environments', None) - - -class ListLabsResponse(msrest.serialization.Model): - """Lists the labs owned by a user. - - :param labs: List of all the labs. - :type labs: list[~azure.mgmt.labservices.models.LabDetails] - """ - - _attribute_map = { - 'labs': {'key': 'labs', 'type': '[LabDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(ListLabsResponse, self).__init__(**kwargs) - self.labs = kwargs.get('labs', None) - - -class NetworkInterface(msrest.serialization.Model): - """Network details of the environment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar private_ip_address: PrivateIp address of the Compute VM. - :vartype private_ip_address: str - :ivar ssh_authority: Connection information for Linux. - :vartype ssh_authority: str - :ivar rdp_authority: Connection information for Windows. - :vartype rdp_authority: str - :ivar username: Username of the VM. - :vartype username: str - """ - - _validation = { - 'private_ip_address': {'readonly': True}, - 'ssh_authority': {'readonly': True}, - 'rdp_authority': {'readonly': True}, - 'username': {'readonly': True}, - } - - _attribute_map = { - 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkInterface, self).__init__(**kwargs) - self.private_ip_address = None - self.ssh_authority = None - self.rdp_authority = None - self.username = None - - -class OperationBatchStatusPayload(msrest.serialization.Model): - """Payload to get the status of an operation. - - All required parameters must be populated in order to send to Azure. - - :param urls: Required. The operation url of long running operation. - :type urls: list[str] - """ - - _validation = { - 'urls': {'required': True}, - } - - _attribute_map = { - 'urls': {'key': 'urls', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationBatchStatusPayload, self).__init__(**kwargs) - self.urls = kwargs['urls'] - - -class OperationBatchStatusResponse(msrest.serialization.Model): - """Status Details of the long running operation for an environment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar items: Gets a collection of items that contain the operation url and status. - :vartype items: list[~azure.mgmt.labservices.models.OperationBatchStatusResponseItem] - """ - - _validation = { - 'items': {'readonly': True}, - } - - _attribute_map = { - 'items': {'key': 'items', 'type': '[OperationBatchStatusResponseItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationBatchStatusResponse, self).__init__(**kwargs) - self.items = None - - -class OperationBatchStatusResponseItem(msrest.serialization.Model): - """Represents the status of an operation that used the batch API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar operation_url: status of the long running operation for an environment. - :vartype operation_url: str - :ivar status: status of the long running operation for an environment. - :vartype status: str - """ - - _validation = { - 'operation_url': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'operation_url': {'key': 'operationUrl', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationBatchStatusResponseItem, self).__init__(**kwargs) - self.operation_url = None - self.status = 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 ManagedLab ResourceProvider. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that describes the operations. - :type display: ~azure.mgmt.labservices.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 error: Error details for the operation in case of a failure. - :type error: ~azure.mgmt.labservices.models.OperationError - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'OperationError'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResult, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.error = kwargs.get('error', None) - - -class OperationStatusPayload(msrest.serialization.Model): - """Payload to get the status of an operation. - - All required parameters must be populated in order to send to Azure. - - :param operation_url: Required. The operation url of long running operation. - :type operation_url: str - """ - - _validation = { - 'operation_url': {'required': True}, - } - - _attribute_map = { - 'operation_url': {'key': 'operationUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationStatusPayload, self).__init__(**kwargs) - self.operation_url = kwargs['operation_url'] - - -class OperationStatusResponse(msrest.serialization.Model): - """Status Details of the long running operation for an environment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: status of the long running operation for an environment. - :vartype status: str - """ - - _validation = { - 'status': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationStatusResponse, self).__init__(**kwargs) - self.status = None - - -class PersonalPreferencesOperationsPayload(msrest.serialization.Model): - """Represents payload for any Environment operations like get, start, stop, connect. - - :param lab_account_resource_id: Resource Id of the lab account. - :type lab_account_resource_id: str - :param add_remove: Enum indicating if user is adding or removing a favorite lab. Possible - values include: "Add", "Remove". - :type add_remove: str or ~azure.mgmt.labservices.models.AddRemove - :param lab_resource_id: Resource Id of the lab to add/remove from the favorites list. - :type lab_resource_id: str - """ - - _attribute_map = { - 'lab_account_resource_id': {'key': 'labAccountResourceId', 'type': 'str'}, - 'add_remove': {'key': 'addRemove', 'type': 'str'}, - 'lab_resource_id': {'key': 'labResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PersonalPreferencesOperationsPayload, self).__init__(**kwargs) - self.lab_account_resource_id = kwargs.get('lab_account_resource_id', None) - self.add_remove = kwargs.get('add_remove', None) - self.lab_resource_id = kwargs.get('lab_resource_id', 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.labservices.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 PublishPayload(msrest.serialization.Model): - """Payload for Publish operation on EnvironmentSetting. - - :param use_existing_image: Whether to use existing VM custom image when publishing. - :type use_existing_image: bool - """ - - _attribute_map = { - 'use_existing_image': {'key': 'useExistingImage', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(PublishPayload, self).__init__(**kwargs) - self.use_existing_image = kwargs.get('use_existing_image', None) - - -class ReferenceVm(msrest.serialization.Model): - """Details of a Reference Vm. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param user_name: Required. The username of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine. This will be set to null in GET resource - API. - :type password: str - :ivar vm_state_details: The state details for the reference virtual machine. - :vartype vm_state_details: ~azure.mgmt.labservices.models.VmStateDetails - :ivar vm_resource_id: VM resource Id for the environment. - :vartype vm_resource_id: str - """ - - _validation = { - 'user_name': {'required': True}, - 'vm_state_details': {'readonly': True}, - 'vm_resource_id': {'readonly': True}, - } - - _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'vm_state_details': {'key': 'vmStateDetails', 'type': 'VmStateDetails'}, - 'vm_resource_id': {'key': 'vmResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReferenceVm, self).__init__(**kwargs) - self.user_name = kwargs['user_name'] - self.password = kwargs.get('password', None) - self.vm_state_details = None - self.vm_resource_id = None - - -class ReferenceVmCreationParameters(msrest.serialization.Model): - """Creation parameters for Reference Vm. - - All required parameters must be populated in order to send to Azure. - - :param user_name: Required. The username of the virtual machine. - :type user_name: str - :param password: Required. The password of the virtual machine. - :type password: str - """ - - _validation = { - 'user_name': {'required': True}, - 'password': {'required': True}, - } - - _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReferenceVmCreationParameters, self).__init__(**kwargs) - self.user_name = kwargs['user_name'] - self.password = kwargs['password'] - - -class ReferenceVmFragment(msrest.serialization.Model): - """Details of a Reference Vm. - - :param user_name: The username of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine. This will be set to null in GET resource - API. - :type password: str - """ - - _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReferenceVmFragment, self).__init__(**kwargs) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - - -class RegionalAvailability(msrest.serialization.Model): - """The availability information of sizes across regions. - - :param region: Corresponding region. - :type region: str - :param size_availabilities: List of all the size information for the region. - :type size_availabilities: list[~azure.mgmt.labservices.models.SizeAvailability] - """ - - _attribute_map = { - 'region': {'key': 'region', 'type': 'str'}, - 'size_availabilities': {'key': 'sizeAvailabilities', 'type': '[SizeAvailability]'}, - } - - def __init__( - self, - **kwargs - ): - super(RegionalAvailability, self).__init__(**kwargs) - self.region = kwargs.get('region', None) - self.size_availabilities = kwargs.get('size_availabilities', None) - - -class RegisterPayload(msrest.serialization.Model): - """Represents payload for Register action. - - :param registration_code: The registration code of the lab. - :type registration_code: str - """ - - _attribute_map = { - 'registration_code': {'key': 'registrationCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegisterPayload, self).__init__(**kwargs) - self.registration_code = kwargs.get('registration_code', None) - - -class ResetPasswordPayload(msrest.serialization.Model): - """Represents the payload for resetting passwords. - - All required parameters must be populated in order to send to Azure. - - :param environment_id: Required. The resourceId of the environment. - :type environment_id: str - :param username: The username for which the password will be reset. - :type username: str - :param password: The password to assign to the user specified in. - :type password: str - """ - - _validation = { - 'environment_id': {'required': True}, - } - - _attribute_map = { - 'environment_id': {'key': 'environmentId', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResetPasswordPayload, self).__init__(**kwargs) - self.environment_id = kwargs['environment_id'] - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) - - -class ResourceSet(msrest.serialization.Model): - """Represents a VM and the setting Id it was created for. - - :param vm_resource_id: VM resource Id for the environment. - :type vm_resource_id: str - :param resource_setting_id: resourceSettingId for the environment. - :type resource_setting_id: str - """ - - _attribute_map = { - 'vm_resource_id': {'key': 'vmResourceId', 'type': 'str'}, - 'resource_setting_id': {'key': 'resourceSettingId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSet, self).__init__(**kwargs) - self.vm_resource_id = kwargs.get('vm_resource_id', None) - self.resource_setting_id = kwargs.get('resource_setting_id', None) - - -class ResourceSetFragment(msrest.serialization.Model): - """Represents a VM and the setting Id it was created for. - - :param vm_resource_id: VM resource Id for the environment. - :type vm_resource_id: str - :param resource_setting_id: resourceSettingId for the environment. - :type resource_setting_id: str - """ - - _attribute_map = { - 'vm_resource_id': {'key': 'vmResourceId', 'type': 'str'}, - 'resource_setting_id': {'key': 'resourceSettingId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSetFragment, self).__init__(**kwargs) - self.vm_resource_id = kwargs.get('vm_resource_id', None) - self.resource_setting_id = kwargs.get('resource_setting_id', None) - - -class ResourceSettingCreationParameters(msrest.serialization.Model): - """Represents resource specific settings. - - All required parameters must be populated in order to send to Azure. - - :param location: The location where the virtual machine will live. - :type location: str - :param name: The name of the resource setting. - :type name: str - :param gallery_image_resource_id: Required. The resource id of the gallery image used for - creating the virtual machine. - :type gallery_image_resource_id: str - :param size: The size of the virtual machine. Possible values include: "Basic", "Standard", - "Performance". - :type size: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param reference_vm_creation_parameters: Required. Creation parameters for Reference Vm. - :type reference_vm_creation_parameters: - ~azure.mgmt.labservices.models.ReferenceVmCreationParameters - """ - - _validation = { - 'gallery_image_resource_id': {'required': True}, - 'reference_vm_creation_parameters': {'required': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'gallery_image_resource_id': {'key': 'galleryImageResourceId', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'reference_vm_creation_parameters': {'key': 'referenceVmCreationParameters', 'type': 'ReferenceVmCreationParameters'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSettingCreationParameters, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.name = kwargs.get('name', None) - self.gallery_image_resource_id = kwargs['gallery_image_resource_id'] - self.size = kwargs.get('size', None) - self.reference_vm_creation_parameters = kwargs['reference_vm_creation_parameters'] - - -class ResourceSettings(msrest.serialization.Model): - """Represents resource specific settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The unique id of the resource setting. - :vartype id: str - :param gallery_image_resource_id: The resource id of the gallery image used for creating the - virtual machine. - :type gallery_image_resource_id: str - :ivar image_name: The name of the image used to created the environment setting. - :vartype image_name: str - :param size: The size of the virtual machine. Possible values include: "Basic", "Standard", - "Performance". - :type size: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :ivar cores: The translated compute cores of the virtual machine. - :vartype cores: int - :param reference_vm: Required. Details specific to Reference Vm. - :type reference_vm: ~azure.mgmt.labservices.models.ReferenceVm - """ - - _validation = { - 'id': {'readonly': True}, - 'image_name': {'readonly': True}, - 'cores': {'readonly': True}, - 'reference_vm': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'gallery_image_resource_id': {'key': 'galleryImageResourceId', 'type': 'str'}, - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'cores': {'key': 'cores', 'type': 'int'}, - 'reference_vm': {'key': 'referenceVm', 'type': 'ReferenceVm'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSettings, self).__init__(**kwargs) - self.id = None - self.gallery_image_resource_id = kwargs.get('gallery_image_resource_id', None) - self.image_name = None - self.size = kwargs.get('size', None) - self.cores = None - self.reference_vm = kwargs['reference_vm'] - - -class ResourceSettingsFragment(msrest.serialization.Model): - """Represents resource specific settings. - - :param gallery_image_resource_id: The resource id of the gallery image used for creating the - virtual machine. - :type gallery_image_resource_id: str - :param size: The size of the virtual machine. Possible values include: "Basic", "Standard", - "Performance". - :type size: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param reference_vm: Details specific to Reference Vm. - :type reference_vm: ~azure.mgmt.labservices.models.ReferenceVmFragment - """ - - _attribute_map = { - 'gallery_image_resource_id': {'key': 'galleryImageResourceId', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'reference_vm': {'key': 'referenceVm', 'type': 'ReferenceVmFragment'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSettingsFragment, self).__init__(**kwargs) - self.gallery_image_resource_id = kwargs.get('gallery_image_resource_id', None) - self.size = kwargs.get('size', None) - self.reference_vm = kwargs.get('reference_vm', None) - - -class ResponseWithContinuationEnvironment(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.Environment] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Environment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResponseWithContinuationEnvironment, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResponseWithContinuationEnvironmentSetting(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.EnvironmentSetting] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[EnvironmentSetting]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResponseWithContinuationEnvironmentSetting, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResponseWithContinuationGalleryImage(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.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(ResponseWithContinuationGalleryImage, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResponseWithContinuationLab(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.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(ResponseWithContinuationLab, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResponseWithContinuationLabAccount(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.LabAccount] - :param next_link: Link for next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[LabAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResponseWithContinuationLabAccount, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResponseWithContinuationUser(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.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(ResponseWithContinuationUser, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SizeAvailability(msrest.serialization.Model): - """Represents the size information. - - :param size_category: The category of the size (Basic, Standard, Performance). Possible values - include: "Basic", "Standard", "Performance". - :type size_category: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param is_available: Whether or not this size category is available. - :type is_available: bool - """ - - _attribute_map = { - 'size_category': {'key': 'sizeCategory', 'type': 'str'}, - 'is_available': {'key': 'isAvailable', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SizeAvailability, self).__init__(**kwargs) - self.size_category = kwargs.get('size_category', None) - self.is_available = kwargs.get('is_available', None) - - -class SizeConfigurationProperties(msrest.serialization.Model): - """Represents the size configuration under the lab account. - - :param environment_sizes: Represents a list of size categories supported by this Lab Account - (Small, Medium, Large). - :type environment_sizes: list[~azure.mgmt.labservices.models.EnvironmentSize] - """ - - _attribute_map = { - 'environment_sizes': {'key': 'environmentSizes', 'type': '[EnvironmentSize]'}, - } - - def __init__( - self, - **kwargs - ): - super(SizeConfigurationProperties, self).__init__(**kwargs) - self.environment_sizes = kwargs.get('environment_sizes', None) - - -class SizeConfigurationPropertiesFragment(msrest.serialization.Model): - """Represents the size configuration under the lab account. - - :param environment_sizes: Represents a list of size categories supported by this Lab Account - (Small, Medium, Large). - :type environment_sizes: list[~azure.mgmt.labservices.models.EnvironmentSizeFragment] - """ - - _attribute_map = { - 'environment_sizes': {'key': 'environmentSizes', 'type': '[EnvironmentSizeFragment]'}, - } - - def __init__( - self, - **kwargs - ): - super(SizeConfigurationPropertiesFragment, self).__init__(**kwargs) - self.environment_sizes = kwargs.get('environment_sizes', None) - - -class SizeInfo(msrest.serialization.Model): - """Contains detailed information about a size. - - :param compute_size: Represents the actual compute size, e.g. Standard_A2_v2. - :type compute_size: str - :param price: The pay-as-you-go price per hour this size will cost. It does not include - discounts and may not reflect the actual price the size will cost. - :type price: float - :param number_of_cores: The number of cores a VM of this size has. - :type number_of_cores: int - :param memory: The amount of memory available (in GB). - :type memory: float - """ - - _attribute_map = { - 'compute_size': {'key': 'computeSize', 'type': 'str'}, - 'price': {'key': 'price', 'type': 'float'}, - 'number_of_cores': {'key': 'numberOfCores', 'type': 'int'}, - 'memory': {'key': 'memory', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(SizeInfo, self).__init__(**kwargs) - self.compute_size = kwargs.get('compute_size', None) - self.price = kwargs.get('price', None) - self.number_of_cores = kwargs.get('number_of_cores', None) - self.memory = kwargs.get('memory', None) - - -class SizeInfoFragment(msrest.serialization.Model): - """Contains detailed information about a size. - - :param compute_size: Represents the actual compute size, e.g. Standard_A2_v2. - :type compute_size: str - :param price: The pay-as-you-go price per hour this size will cost. It does not include - discounts and may not reflect the actual price the size will cost. - :type price: float - :param number_of_cores: The number of cores a VM of this size has. - :type number_of_cores: int - :param memory: The amount of memory available (in GB). - :type memory: float - """ - - _attribute_map = { - 'compute_size': {'key': 'computeSize', 'type': 'str'}, - 'price': {'key': 'price', 'type': 'float'}, - 'number_of_cores': {'key': 'numberOfCores', 'type': 'int'}, - 'memory': {'key': 'memory', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(SizeInfoFragment, self).__init__(**kwargs) - self.compute_size = kwargs.get('compute_size', None) - self.price = kwargs.get('price', None) - self.number_of_cores = kwargs.get('number_of_cores', None) - self.memory = kwargs.get('memory', None) - - -class User(Resource): - """The User registered to 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 email: The user email address, as it was specified during registration. - :vartype email: str - :ivar family_name: The user family name, as it was specified during registration. - :vartype family_name: str - :ivar given_name: The user given name, as it was specified during registration. - :vartype given_name: str - :ivar tenant_id: The user tenant ID, as it was specified during registration. - :vartype tenant_id: str - :ivar total_usage: How long the user has used his VMs in this lab. - :vartype total_usage: ~datetime.timedelta - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'email': {'readonly': True}, - 'family_name': {'readonly': True}, - 'given_name': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'total_usage': {'readonly': True}, - 'latest_operation_result': {'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}'}, - 'email': {'key': 'properties.email', 'type': 'str'}, - 'family_name': {'key': 'properties.familyName', 'type': 'str'}, - 'given_name': {'key': 'properties.givenName', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'total_usage': {'key': 'properties.totalUsage', 'type': 'duration'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.email = None - self.family_name = None - self.given_name = None - self.tenant_id = None - self.total_usage = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - self.latest_operation_result = None - - -class UserFragment(Resource): - """The User registered to 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] - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: 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}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserFragment, self).__init__(**kwargs) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.unique_identifier = kwargs.get('unique_identifier', None) - - -class VirtualMachineDetails(msrest.serialization.Model): - """Details of the backing virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning state of the Dtl VM. - :vartype provisioning_state: str - :ivar rdp_authority: Connection information for Windows. - :vartype rdp_authority: str - :ivar ssh_authority: Connection information for Linux. - :vartype ssh_authority: str - :ivar private_ip_address: PrivateIp address of the compute VM. - :vartype private_ip_address: str - :ivar user_name: Compute VM login user name. - :vartype user_name: str - :ivar last_known_power_state: Last known compute power state captured in DTL. - :vartype last_known_power_state: str - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'rdp_authority': {'readonly': True}, - 'ssh_authority': {'readonly': True}, - 'private_ip_address': {'readonly': True}, - 'user_name': {'readonly': True}, - 'last_known_power_state': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, - 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'last_known_power_state': {'key': 'lastKnownPowerState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachineDetails, self).__init__(**kwargs) - self.provisioning_state = None - self.rdp_authority = None - self.ssh_authority = None - self.private_ip_address = None - self.user_name = None - self.last_known_power_state = None - - -class VmStateDetails(msrest.serialization.Model): - """Details about the state of the reference virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 power_state: The power state of the reference virtual machine. - :vartype power_state: str - :ivar last_known_power_state: Last known compute power state captured in DTL. - :vartype last_known_power_state: str - """ - - _validation = { - 'rdp_authority': {'readonly': True}, - 'ssh_authority': {'readonly': True}, - 'power_state': {'readonly': True}, - 'last_known_power_state': {'readonly': True}, - } - - _attribute_map = { - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, - 'power_state': {'key': 'powerState', 'type': 'str'}, - 'last_known_power_state': {'key': 'lastKnownPowerState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VmStateDetails, self).__init__(**kwargs) - self.rdp_authority = None - self.ssh_authority = None - self.power_state = None - self.last_known_power_state = None diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_models_py3.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_models_py3.py index bfe8d872e419..8a324fcc3708 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_models_py3.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/models/_models_py3.py @@ -9,362 +9,293 @@ import datetime from typing import Dict, List, Optional, Union +from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._managed_labs_client_enums import * +from ._lab_services_client_enums import * -class AddUsersPayload(msrest.serialization.Model): - """Payload for Add Users operation on a Lab. +class AutoShutdownProfile(msrest.serialization.Model): + """Profile for how to handle shutting down virtual machines. - All required parameters must be populated in order to send to Azure. - - :param email_addresses: Required. List of user emails addresses to add to the lab. - :type email_addresses: list[str] + :ivar shutdown_on_disconnect: Whether shutdown on disconnect is enabled. Possible values + include: "Enabled", "Disabled". + :vartype shutdown_on_disconnect: str or ~azure.mgmt.labservices.models.EnableState + :ivar shutdown_when_not_connected: Whether a VM will get shutdown when it hasn't been connected + to after a period of time. Possible values include: "Enabled", "Disabled". + :vartype shutdown_when_not_connected: str or ~azure.mgmt.labservices.models.EnableState + :ivar shutdown_on_idle: Whether a VM will get shutdown when it has idled for a period of time. + Possible values include: "None", "UserAbsence", "LowUsage". + :vartype shutdown_on_idle: str or ~azure.mgmt.labservices.models.ShutdownOnIdleMode + :ivar disconnect_delay: The amount of time a VM will stay running after a user disconnects if + this behavior is enabled. + :vartype disconnect_delay: ~datetime.timedelta + :ivar no_connect_delay: The amount of time a VM will stay running before it is shutdown if no + connection is made and this behavior is enabled. + :vartype no_connect_delay: ~datetime.timedelta + :ivar idle_delay: The amount of time a VM will idle before it is shutdown if this behavior is + enabled. + :vartype idle_delay: ~datetime.timedelta """ - _validation = { - 'email_addresses': {'required': True}, - } - _attribute_map = { - 'email_addresses': {'key': 'emailAddresses', 'type': '[str]'}, + 'shutdown_on_disconnect': {'key': 'shutdownOnDisconnect', 'type': 'str'}, + 'shutdown_when_not_connected': {'key': 'shutdownWhenNotConnected', 'type': 'str'}, + 'shutdown_on_idle': {'key': 'shutdownOnIdle', 'type': 'str'}, + 'disconnect_delay': {'key': 'disconnectDelay', 'type': 'duration'}, + 'no_connect_delay': {'key': 'noConnectDelay', 'type': 'duration'}, + 'idle_delay': {'key': 'idleDelay', 'type': 'duration'}, } def __init__( self, *, - email_addresses: List[str], - **kwargs - ): - super(AddUsersPayload, self).__init__(**kwargs) - self.email_addresses = email_addresses - - -class CloudErrorBody(msrest.serialization.Model): - """Body of an error from a REST request. - - :param code: - :type code: str - :param message: - :type message: str - :param target: - :type target: str - :param details: Inner errors. - :type details: list[~azure.mgmt.labservices.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + shutdown_on_disconnect: Optional[Union[str, "EnableState"]] = None, + shutdown_when_not_connected: Optional[Union[str, "EnableState"]] = None, + shutdown_on_idle: Optional[Union[str, "ShutdownOnIdleMode"]] = None, + disconnect_delay: Optional[datetime.timedelta] = None, + no_connect_delay: Optional[datetime.timedelta] = None, + idle_delay: Optional[datetime.timedelta] = None, + **kwargs + ): + """ + :keyword shutdown_on_disconnect: Whether shutdown on disconnect is enabled. Possible values + include: "Enabled", "Disabled". + :paramtype shutdown_on_disconnect: str or ~azure.mgmt.labservices.models.EnableState + :keyword shutdown_when_not_connected: Whether a VM will get shutdown when it hasn't been + connected to after a period of time. Possible values include: "Enabled", "Disabled". + :paramtype shutdown_when_not_connected: str or ~azure.mgmt.labservices.models.EnableState + :keyword shutdown_on_idle: Whether a VM will get shutdown when it has idled for a period of + time. Possible values include: "None", "UserAbsence", "LowUsage". + :paramtype shutdown_on_idle: str or ~azure.mgmt.labservices.models.ShutdownOnIdleMode + :keyword disconnect_delay: The amount of time a VM will stay running after a user disconnects + if this behavior is enabled. + :paramtype disconnect_delay: ~datetime.timedelta + :keyword no_connect_delay: The amount of time a VM will stay running before it is shutdown if + no connection is made and this behavior is enabled. + :paramtype no_connect_delay: ~datetime.timedelta + :keyword idle_delay: The amount of time a VM will idle before it is shutdown if this behavior + is enabled. + :paramtype idle_delay: ~datetime.timedelta + """ + super(AutoShutdownProfile, self).__init__(**kwargs) + self.shutdown_on_disconnect = shutdown_on_disconnect + self.shutdown_when_not_connected = shutdown_when_not_connected + self.shutdown_on_idle = shutdown_on_idle + self.disconnect_delay = disconnect_delay + self.no_connect_delay = no_connect_delay + self.idle_delay = idle_delay + + +class ConnectionProfile(msrest.serialization.Model): + """Connection profile for how users connect to lab virtual machines. + + :ivar web_ssh_access: The enabled access level for Web Access over SSH. Possible values + include: "Public", "Private", "None". + :vartype web_ssh_access: str or ~azure.mgmt.labservices.models.ConnectionType + :ivar web_rdp_access: The enabled access level for Web Access over RDP. Possible values + include: "Public", "Private", "None". + :vartype web_rdp_access: str or ~azure.mgmt.labservices.models.ConnectionType + :ivar client_ssh_access: The enabled access level for Client Access over SSH. Possible values + include: "Public", "Private", "None". + :vartype client_ssh_access: str or ~azure.mgmt.labservices.models.ConnectionType + :ivar client_rdp_access: The enabled access level for Client Access over RDP. Possible values + include: "Public", "Private", "None". + :vartype client_rdp_access: str or ~azure.mgmt.labservices.models.ConnectionType + """ + + _attribute_map = { + 'web_ssh_access': {'key': 'webSshAccess', 'type': 'str'}, + 'web_rdp_access': {'key': 'webRdpAccess', 'type': 'str'}, + 'client_ssh_access': {'key': 'clientSshAccess', 'type': 'str'}, + 'client_rdp_access': {'key': 'clientRdpAccess', 'type': 'str'}, } def __init__( self, *, - code: Optional[str] = None, - message: Optional[str] = None, - target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = code - self.message = message - self.target = target - self.details = details - - -class CreateLabProperties(msrest.serialization.Model): - """Properties for creating a managed lab and a default environment setting. + web_ssh_access: Optional[Union[str, "ConnectionType"]] = None, + web_rdp_access: Optional[Union[str, "ConnectionType"]] = None, + client_ssh_access: Optional[Union[str, "ConnectionType"]] = None, + client_rdp_access: Optional[Union[str, "ConnectionType"]] = None, + **kwargs + ): + """ + :keyword web_ssh_access: The enabled access level for Web Access over SSH. Possible values + include: "Public", "Private", "None". + :paramtype web_ssh_access: str or ~azure.mgmt.labservices.models.ConnectionType + :keyword web_rdp_access: The enabled access level for Web Access over RDP. Possible values + include: "Public", "Private", "None". + :paramtype web_rdp_access: str or ~azure.mgmt.labservices.models.ConnectionType + :keyword client_ssh_access: The enabled access level for Client Access over SSH. Possible + values include: "Public", "Private", "None". + :paramtype client_ssh_access: str or ~azure.mgmt.labservices.models.ConnectionType + :keyword client_rdp_access: The enabled access level for Client Access over RDP. Possible + values include: "Public", "Private", "None". + :paramtype client_rdp_access: str or ~azure.mgmt.labservices.models.ConnectionType + """ + super(ConnectionProfile, self).__init__(**kwargs) + self.web_ssh_access = web_ssh_access + self.web_rdp_access = web_rdp_access + self.client_ssh_access = client_ssh_access + self.client_rdp_access = client_rdp_access + + +class Credentials(msrest.serialization.Model): + """Credentials for a user on a lab VM. All required parameters must be populated in order to send to Azure. - :param environment_setting_creation_parameters: Settings related to creating an environment - setting. - :type environment_setting_creation_parameters: - ~azure.mgmt.labservices.models.EnvironmentSettingCreationParameters - :param lab_creation_parameters: Required. Settings related to creating a lab. - :type lab_creation_parameters: ~azure.mgmt.labservices.models.LabCreationParameters - :param name: Required. The name of the resource. - :type name: 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 username: Required. The username to use when signing in to lab VMs. + :vartype username: str + :ivar password: The password for the user. This is required for the TemplateVM createOption. + :vartype password: str """ _validation = { - 'lab_creation_parameters': {'required': True}, - 'name': {'required': True}, + 'username': {'required': True}, } _attribute_map = { - 'environment_setting_creation_parameters': {'key': 'environmentSettingCreationParameters', 'type': 'EnvironmentSettingCreationParameters'}, - 'lab_creation_parameters': {'key': 'labCreationParameters', 'type': 'LabCreationParameters'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'username': {'key': 'username', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, } def __init__( self, *, - lab_creation_parameters: "LabCreationParameters", - name: str, - environment_setting_creation_parameters: Optional["EnvironmentSettingCreationParameters"] = None, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, + username: str, + password: Optional[str] = None, **kwargs ): - super(CreateLabProperties, self).__init__(**kwargs) - self.environment_setting_creation_parameters = environment_setting_creation_parameters - self.lab_creation_parameters = lab_creation_parameters - self.name = name - self.location = location - self.tags = tags + """ + :keyword username: Required. The username to use when signing in to lab VMs. + :paramtype username: str + :keyword password: The password for the user. This is required for the TemplateVM createOption. + :paramtype password: str + """ + super(Credentials, self).__init__(**kwargs) + self.username = username + self.password = password -class Resource(msrest.serialization.Model): - """An Azure resource. +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. - :ivar 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. + :ivar type: The additional info type. :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 info: The additional info. + :vartype info: any """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, 'type': {'readonly': True}, + 'info': {'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}'}, + 'info': {'key': 'info', 'type': 'object'}, } def __init__( self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, **kwargs ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None + """ + """ + super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None - self.location = location - self.tags = tags + self.info = None -class Environment(Resource): - """Represents an environment instance. +class ErrorDetail(msrest.serialization.Model): + """The error detail. 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 resource_sets: The set of a VM and the setting id it was created for. - :type resource_sets: ~azure.mgmt.labservices.models.ResourceSet - :ivar claimed_by_user_object_id: The AAD object Id of the user who has claimed the environment. - :vartype claimed_by_user_object_id: str - :ivar claimed_by_user_principal_id: The user principal Id of the user who has claimed the - environment. - :vartype claimed_by_user_principal_id: str - :ivar claimed_by_user_name: The name or email address of the user who has claimed the - environment. - :vartype claimed_by_user_name: str - :ivar is_claimed: Is the environment claimed or not. - :vartype is_claimed: bool - :ivar last_known_power_state: Last known power state of the environment. - :vartype last_known_power_state: str - :ivar network_interface: Network details of the environment. - :vartype network_interface: ~azure.mgmt.labservices.models.NetworkInterface - :ivar total_usage: How long the environment has been used by a lab user. - :vartype total_usage: ~datetime.timedelta - :ivar password_last_reset: When the password was last reset on the environment. - :vartype password_last_reset: ~datetime.datetime - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.labservices.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.labservices.models.ErrorAdditionalInfo] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'claimed_by_user_object_id': {'readonly': True}, - 'claimed_by_user_principal_id': {'readonly': True}, - 'claimed_by_user_name': {'readonly': True}, - 'is_claimed': {'readonly': True}, - 'last_known_power_state': {'readonly': True}, - 'network_interface': {'readonly': True}, - 'total_usage': {'readonly': True}, - 'password_last_reset': {'readonly': True}, - 'latest_operation_result': {'readonly': True}, + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'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}'}, - 'resource_sets': {'key': 'properties.resourceSets', 'type': 'ResourceSet'}, - 'claimed_by_user_object_id': {'key': 'properties.claimedByUserObjectId', 'type': 'str'}, - 'claimed_by_user_principal_id': {'key': 'properties.claimedByUserPrincipalId', 'type': 'str'}, - 'claimed_by_user_name': {'key': 'properties.claimedByUserName', 'type': 'str'}, - 'is_claimed': {'key': 'properties.isClaimed', 'type': 'bool'}, - 'last_known_power_state': {'key': 'properties.lastKnownPowerState', 'type': 'str'}, - 'network_interface': {'key': 'properties.networkInterface', 'type': 'NetworkInterface'}, - 'total_usage': {'key': 'properties.totalUsage', 'type': 'duration'}, - 'password_last_reset': {'key': 'properties.passwordLastReset', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } def __init__( self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - resource_sets: Optional["ResourceSet"] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, - **kwargs - ): - super(Environment, self).__init__(location=location, tags=tags, **kwargs) - self.resource_sets = resource_sets - self.claimed_by_user_object_id = None - self.claimed_by_user_principal_id = None - self.claimed_by_user_name = None - self.is_claimed = None - self.last_known_power_state = None - self.network_interface = None - self.total_usage = None - self.password_last_reset = None - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - self.latest_operation_result = None - + **kwargs + ): + """ + """ + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None -class EnvironmentDetails(msrest.serialization.Model): - """This represents the details about a User's environment and its state. - Variables are only populated by the server, and will be ignored when sending a request. +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :ivar name: Name of the Environment. - :vartype name: str - :ivar description: Description of the Environment. - :vartype description: str - :ivar id: Resource Id of the environment. - :vartype id: str - :ivar provisioning_state: The provisioning state of the environment. This also includes - LabIsFull and NotYetProvisioned status. - :vartype provisioning_state: str - :ivar virtual_machine_details: Details of backing DTL virtual machine with compute and network - details. - :vartype virtual_machine_details: ~azure.mgmt.labservices.models.VirtualMachineDetails - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - :ivar environment_state: Publishing state of the environment setting Possible values are - Creating, Created, Failed. - :vartype environment_state: str - :ivar total_usage: How long the environment has been used by a lab user. - :vartype total_usage: ~datetime.timedelta - :ivar password_last_reset: When the password was last reset on the environment. - :vartype password_last_reset: ~datetime.datetime + :ivar error: The error object. + :vartype error: ~azure.mgmt.labservices.models.ErrorDetail """ - _validation = { - 'name': {'readonly': True}, - 'description': {'readonly': True}, - 'id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'virtual_machine_details': {'readonly': True}, - 'latest_operation_result': {'readonly': True}, - 'environment_state': {'readonly': True}, - 'total_usage': {'readonly': True}, - 'password_last_reset': {'readonly': True}, - } - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'virtual_machine_details': {'key': 'virtualMachineDetails', 'type': 'VirtualMachineDetails'}, - 'latest_operation_result': {'key': 'latestOperationResult', 'type': 'LatestOperationResult'}, - 'environment_state': {'key': 'environmentState', 'type': 'str'}, - 'total_usage': {'key': 'totalUsage', 'type': 'duration'}, - 'password_last_reset': {'key': 'passwordLastReset', 'type': 'iso-8601'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, } def __init__( self, + *, + error: Optional["ErrorDetail"] = None, **kwargs ): - super(EnvironmentDetails, self).__init__(**kwargs) - self.name = None - self.description = None - self.id = None - self.provisioning_state = None - self.virtual_machine_details = None - self.latest_operation_result = None - self.environment_state = None - self.total_usage = None - self.password_last_reset = None + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.labservices.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error -class EnvironmentFragment(Resource): - """Represents an environment instance. +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The identifier of the resource. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :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 resource_sets: The set of a VM and the setting id it was created for. - :type resource_sets: ~azure.mgmt.labservices.models.ResourceSetFragment - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str """ _validation = { @@ -377,2383 +308,3370 @@ class EnvironmentFragment(Resource): '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}'}, - 'resource_sets': {'key': 'properties.resourceSets', 'type': 'ResourceSetFragment'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, } def __init__( self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - resource_sets: Optional["ResourceSetFragment"] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, **kwargs ): - super(EnvironmentFragment, self).__init__(location=location, tags=tags, **kwargs) - self.resource_sets = resource_sets - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - - -class EnvironmentOperationsPayload(msrest.serialization.Model): - """Represents payload for any Environment operations like get, start, stop, connect. - - All required parameters must be populated in order to send to Azure. - - :param environment_id: Required. The resourceId of the environment. - :type environment_id: str - """ - - _validation = { - 'environment_id': {'required': True}, - } - - _attribute_map = { - 'environment_id': {'key': 'environmentId', 'type': 'str'}, - } - - def __init__( - self, - *, - environment_id: str, - **kwargs - ): - super(EnvironmentOperationsPayload, self).__init__(**kwargs) - self.environment_id = environment_id + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None -class EnvironmentSetting(Resource): - """Represents settings of an environment, from which environment instances would be created. +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The identifier of the resource. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :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 publishing_state: Describes the readiness of this environment setting. Possible values - include: "Draft", "Publishing", "Published", "PublishFailed", "Scaling". - :vartype publishing_state: str or ~azure.mgmt.labservices.models.PublishingState - :param configuration_state: Describes the user's progress in configuring their environment - setting. Possible values include: "NotApplicable", "Completed". - :type configuration_state: str or ~azure.mgmt.labservices.models.ConfigurationState - :param description: Describes the environment and its resource settings. - :type description: str - :param title: Brief title describing the environment and its resource settings. - :type title: str - :param resource_settings: The resource specific settings. - :type resource_settings: ~azure.mgmt.labservices.models.ResourceSettings - :ivar last_changed: Time when the template VM was last changed. - :vartype last_changed: ~datetime.datetime - :ivar last_published: Time when the template VM was last sent for publishing. - :vartype last_published: ~datetime.datetime - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'publishing_state': {'readonly': True}, - 'last_changed': {'readonly': True}, - 'last_published': {'readonly': True}, - 'latest_operation_result': {'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}'}, - 'publishing_state': {'key': 'properties.publishingState', 'type': 'str'}, - 'configuration_state': {'key': 'properties.configurationState', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'resource_settings': {'key': 'properties.resourceSettings', 'type': 'ResourceSettings'}, - 'last_changed': {'key': 'properties.lastChanged', 'type': 'iso-8601'}, - 'last_published': {'key': 'properties.lastPublished', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, } def __init__( self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - configuration_state: Optional[Union[str, "ConfigurationState"]] = None, - description: Optional[str] = None, - title: Optional[str] = None, - resource_settings: Optional["ResourceSettings"] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, **kwargs ): - super(EnvironmentSetting, self).__init__(location=location, tags=tags, **kwargs) - self.publishing_state = None - self.configuration_state = configuration_state - self.description = description - self.title = title - self.resource_settings = resource_settings - self.last_changed = None - self.last_published = None - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - self.latest_operation_result = None + """ + """ + super(ProxyResource, self).__init__(**kwargs) -class EnvironmentSettingCreationParameters(msrest.serialization.Model): - """Settings related to creating an environment setting. - - All required parameters must be populated in order to send to Azure. - - :param resource_setting_creation_parameters: Required. The resource specific settings. - :type resource_setting_creation_parameters: - ~azure.mgmt.labservices.models.ResourceSettingCreationParameters - """ - - _validation = { - 'resource_setting_creation_parameters': {'required': True}, - } - - _attribute_map = { - 'resource_setting_creation_parameters': {'key': 'resourceSettingCreationParameters', 'type': 'ResourceSettingCreationParameters'}, - } - - def __init__( - self, - *, - resource_setting_creation_parameters: "ResourceSettingCreationParameters", - **kwargs - ): - super(EnvironmentSettingCreationParameters, self).__init__(**kwargs) - self.resource_setting_creation_parameters = resource_setting_creation_parameters - - -class EnvironmentSettingFragment(Resource): - """Represents settings of an environment, from which environment instances would be created. +class Image(ProxyResource): + """Lab services virtual machine image. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The identifier of the resource. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :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 configuration_state: Describes the user's progress in configuring their environment - setting. Possible values include: "NotApplicable", "Completed". - :type configuration_state: str or ~azure.mgmt.labservices.models.ConfigurationState - :param description: Describes the environment and its resource settings. - :type description: str - :param title: Brief title describing the environment and its resource settings. - :type title: str - :param resource_settings: The resource specific settings. - :type resource_settings: ~azure.mgmt.labservices.models.ResourceSettingsFragment - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str + :ivar system_data: Metadata pertaining to creation and last modification of the image. + :vartype system_data: ~azure.mgmt.labservices.models.SystemData + :ivar enabled_state: Is the image enabled. Possible values include: "Enabled", "Disabled". + :vartype enabled_state: str or ~azure.mgmt.labservices.models.EnableState + :ivar provisioning_state: Current provisioning state of the image. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState + :ivar display_name: The image display name. + :vartype display_name: str + :ivar description: A description of the image. + :vartype description: str + :ivar icon_url: URL of the image icon. + :vartype icon_url: str + :ivar author: The image author. + :vartype author: str + :ivar os_type: The OS Type of the image. Possible values include: "Windows", "Linux". + :vartype os_type: str or ~azure.mgmt.labservices.models.OsType + :ivar plan: The ID of marketplace plan associated with the image (optional). + :vartype plan: str + :ivar terms_status: The status of image terms of use (enabled = accepted, disabled = not + accepted). Possible values include: "Enabled", "Disabled". + :vartype terms_status: str or ~azure.mgmt.labservices.models.EnableState + :ivar offer: The ID of an offer associated with the image. + :vartype offer: str + :ivar publisher: The ID of the publisher of the image. + :vartype publisher: str + :ivar sku: The image SKU. + :vartype sku: str + :ivar version: The image version. + :vartype version: str + :ivar shared_gallery_id: The ID for the image in the shared gallery. + :vartype shared_gallery_id: str + :ivar available_regions: The available regions of the image in the shared gallery. + :vartype available_regions: list[str] + :ivar os_state: The OS State of the image. Possible values include: "Generalized", + "Specialized". + :vartype os_state: str or ~azure.mgmt.labservices.models.OsState """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'display_name': {'readonly': True}, + 'description': {'readonly': True}, + 'icon_url': {'readonly': True}, + 'author': {'readonly': True}, + 'os_type': {'readonly': True}, + 'plan': {'readonly': True}, + 'terms_status': {'readonly': True}, + 'offer': {'readonly': True}, + 'publisher': {'readonly': True}, + 'sku': {'readonly': True}, + 'version': {'readonly': True}, + 'shared_gallery_id': {'readonly': True, 'max_length': 2000, 'min_length': 3}, + 'os_state': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'configuration_state': {'key': 'properties.configurationState', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'resource_settings': {'key': 'properties.resourceSettings', 'type': 'ResourceSettingsFragment'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'enabled_state': {'key': 'properties.enabledState', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - configuration_state: Optional[Union[str, "ConfigurationState"]] = None, - description: Optional[str] = None, - title: Optional[str] = None, - resource_settings: Optional["ResourceSettingsFragment"] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, - **kwargs - ): - super(EnvironmentSettingFragment, self).__init__(location=location, tags=tags, **kwargs) - self.configuration_state = configuration_state - self.description = description - self.title = title - self.resource_settings = resource_settings - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - - -class EnvironmentSize(msrest.serialization.Model): - """Represents a size category supported by this Lab Account (small, medium or large). - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: The size category. Possible values include: "Basic", "Standard", "Performance". - :type name: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param vm_sizes: Represents a set of compute sizes that can serve this given size type. - :type vm_sizes: list[~azure.mgmt.labservices.models.SizeInfo] - :ivar max_price: The pay-as-you-go dollar price per hour this size will cost. It does not - include discounts and may not reflect the actual price the size will cost. This is the maximum - price of all prices within this tier. - :vartype max_price: float - :ivar min_number_of_cores: The number of cores a VM of this size has. This is the minimum - number of cores within this tier. - :vartype min_number_of_cores: int - :ivar min_memory: The amount of memory available (in GB). This is the minimum amount of memory - within this tier. - :vartype min_memory: float - """ - - _validation = { - 'max_price': {'readonly': True}, - 'min_number_of_cores': {'readonly': True}, - 'min_memory': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'vm_sizes': {'key': 'vmSizes', 'type': '[SizeInfo]'}, - 'max_price': {'key': 'maxPrice', 'type': 'float'}, - 'min_number_of_cores': {'key': 'minNumberOfCores', 'type': 'int'}, - 'min_memory': {'key': 'minMemory', 'type': 'float'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'icon_url': {'key': 'properties.iconUrl', 'type': 'str'}, + 'author': {'key': 'properties.author', 'type': 'str'}, + 'os_type': {'key': 'properties.osType', 'type': 'str'}, + 'plan': {'key': 'properties.plan', 'type': 'str'}, + 'terms_status': {'key': 'properties.termsStatus', 'type': 'str'}, + 'offer': {'key': 'properties.offer', 'type': 'str'}, + 'publisher': {'key': 'properties.publisher', 'type': 'str'}, + 'sku': {'key': 'properties.sku', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'shared_gallery_id': {'key': 'properties.sharedGalleryId', 'type': 'str'}, + 'available_regions': {'key': 'properties.availableRegions', 'type': '[str]'}, + 'os_state': {'key': 'properties.osState', 'type': 'str'}, } def __init__( self, *, - name: Optional[Union[str, "ManagedLabVmSize"]] = None, - vm_sizes: Optional[List["SizeInfo"]] = None, - **kwargs - ): - super(EnvironmentSize, self).__init__(**kwargs) - self.name = name - self.vm_sizes = vm_sizes - self.max_price = None - self.min_number_of_cores = None - self.min_memory = None + enabled_state: Optional[Union[str, "EnableState"]] = None, + available_regions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword enabled_state: Is the image enabled. Possible values include: "Enabled", "Disabled". + :paramtype enabled_state: str or ~azure.mgmt.labservices.models.EnableState + :keyword available_regions: The available regions of the image in the shared gallery. + :paramtype available_regions: list[str] + """ + super(Image, self).__init__(**kwargs) + self.system_data = None + self.enabled_state = enabled_state + self.provisioning_state = None + self.display_name = None + self.description = None + self.icon_url = None + self.author = None + self.os_type = None + self.plan = None + self.terms_status = None + self.offer = None + self.publisher = None + self.sku = None + self.version = None + self.shared_gallery_id = None + self.available_regions = available_regions + self.os_state = None -class EnvironmentSizeFragment(msrest.serialization.Model): - """Represents a size category supported by this Lab Account (small, medium or large). +class ImageUpdateProperties(msrest.serialization.Model): + """Properties of an image resource update. - :param name: The size category. Possible values include: "Basic", "Standard", "Performance". - :type name: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param vm_sizes: Represents a set of compute sizes that can serve this given size type. - :type vm_sizes: list[~azure.mgmt.labservices.models.SizeInfoFragment] + :ivar enabled_state: Is the image enabled. Possible values include: "Enabled", "Disabled". + :vartype enabled_state: str or ~azure.mgmt.labservices.models.EnableState """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'vm_sizes': {'key': 'vmSizes', 'type': '[SizeInfoFragment]'}, + 'enabled_state': {'key': 'enabledState', 'type': 'str'}, } def __init__( self, *, - name: Optional[Union[str, "ManagedLabVmSize"]] = None, - vm_sizes: Optional[List["SizeInfoFragment"]] = None, + enabled_state: Optional[Union[str, "EnableState"]] = None, **kwargs ): - super(EnvironmentSizeFragment, self).__init__(**kwargs) - self.name = name - self.vm_sizes = vm_sizes + """ + :keyword enabled_state: Is the image enabled. Possible values include: "Enabled", "Disabled". + :paramtype enabled_state: str or ~azure.mgmt.labservices.models.EnableState + """ + super(ImageUpdateProperties, self).__init__(**kwargs) + self.enabled_state = enabled_state -class GalleryImage(Resource): - """Represents an image from the Azure Marketplace. +class ImageProperties(ImageUpdateProperties): + """Properties of an image 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] - :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 - :ivar description: The description of the gallery image. + :ivar enabled_state: Is the image enabled. Possible values include: "Enabled", "Disabled". + :vartype enabled_state: str or ~azure.mgmt.labservices.models.EnableState + :ivar provisioning_state: Current provisioning state of the image. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState + :ivar display_name: The image display name. + :vartype display_name: str + :ivar description: A description of the image. :vartype description: str - :ivar image_reference: The image reference of the gallery image. - :vartype image_reference: ~azure.mgmt.labservices.models.GalleryImageReference - :ivar icon: The icon of the gallery image. - :vartype icon: str - :param is_enabled: Indicates whether this gallery image is enabled. - :type is_enabled: bool - :param is_override: Indicates whether this gallery has been overridden for this lab account. - :type is_override: bool - :ivar plan_id: The third party plan that applies to this image. - :vartype plan_id: str - :param is_plan_authorized: Indicates if the plan has been authorized for programmatic - deployment. - :type is_plan_authorized: bool - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult + :ivar icon_url: URL of the image icon. + :vartype icon_url: str + :ivar author: The image author. + :vartype author: str + :ivar os_type: The OS Type of the image. Possible values include: "Windows", "Linux". + :vartype os_type: str or ~azure.mgmt.labservices.models.OsType + :ivar plan: The ID of marketplace plan associated with the image (optional). + :vartype plan: str + :ivar terms_status: The status of image terms of use (enabled = accepted, disabled = not + accepted). Possible values include: "Enabled", "Disabled". + :vartype terms_status: str or ~azure.mgmt.labservices.models.EnableState + :ivar offer: The ID of an offer associated with the image. + :vartype offer: str + :ivar publisher: The ID of the publisher of the image. + :vartype publisher: str + :ivar sku: The image SKU. + :vartype sku: str + :ivar version: The image version. + :vartype version: str + :ivar shared_gallery_id: The ID for the image in the shared gallery. + :vartype shared_gallery_id: str + :ivar available_regions: The available regions of the image in the shared gallery. + :vartype available_regions: list[str] + :ivar os_state: The OS State of the image. Possible values include: "Generalized", + "Specialized". + :vartype os_state: str or ~azure.mgmt.labservices.models.OsState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'author': {'readonly': True}, - 'created_date': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'display_name': {'readonly': True}, 'description': {'readonly': True}, - 'image_reference': {'readonly': True}, - 'icon': {'readonly': True}, - 'plan_id': {'readonly': True}, - 'latest_operation_result': {'readonly': True}, + 'icon_url': {'readonly': True}, + 'author': {'readonly': True}, + 'os_type': {'readonly': True}, + 'plan': {'readonly': True}, + 'terms_status': {'readonly': True}, + 'offer': {'readonly': True}, + 'publisher': {'readonly': True}, + 'sku': {'readonly': True}, + 'version': {'readonly': True}, + 'shared_gallery_id': {'readonly': True, 'max_length': 2000, 'min_length': 3}, + 'os_state': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - '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'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'is_override': {'key': 'properties.isOverride', 'type': 'bool'}, - 'plan_id': {'key': 'properties.planId', 'type': 'str'}, - 'is_plan_authorized': {'key': 'properties.isPlanAuthorized', 'type': 'bool'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, + 'enabled_state': {'key': 'enabledState', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'icon_url': {'key': 'iconUrl', 'type': 'str'}, + 'author': {'key': 'author', 'type': 'str'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'plan': {'key': 'plan', 'type': 'str'}, + 'terms_status': {'key': 'termsStatus', 'type': 'str'}, + 'offer': {'key': 'offer', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + 'shared_gallery_id': {'key': 'sharedGalleryId', 'type': 'str'}, + 'available_regions': {'key': 'availableRegions', 'type': '[str]'}, + 'os_state': {'key': 'osState', 'type': 'str'}, } def __init__( self, *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - is_enabled: Optional[bool] = None, - is_override: Optional[bool] = None, - is_plan_authorized: Optional[bool] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, + enabled_state: Optional[Union[str, "EnableState"]] = None, + available_regions: Optional[List[str]] = None, **kwargs ): - super(GalleryImage, self).__init__(location=location, tags=tags, **kwargs) - self.author = None - self.created_date = None + """ + :keyword enabled_state: Is the image enabled. Possible values include: "Enabled", "Disabled". + :paramtype enabled_state: str or ~azure.mgmt.labservices.models.EnableState + :keyword available_regions: The available regions of the image in the shared gallery. + :paramtype available_regions: list[str] + """ + super(ImageProperties, self).__init__(enabled_state=enabled_state, **kwargs) + self.provisioning_state = None + self.display_name = None self.description = None - self.image_reference = None - self.icon = None - self.is_enabled = is_enabled - self.is_override = is_override - self.plan_id = None - self.is_plan_authorized = is_plan_authorized - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - self.latest_operation_result = None + self.icon_url = None + self.author = None + self.os_type = None + self.plan = None + self.terms_status = None + self.offer = None + self.publisher = None + self.sku = None + self.version = None + self.shared_gallery_id = None + self.available_regions = available_regions + self.os_state = None -class GalleryImageFragment(Resource): - """Represents an image from the Azure Marketplace. +class ImageReference(msrest.serialization.Model): + """Image reference information. Used in the virtual machine profile. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The identifier of the resource. + :ivar id: Image resource ID. :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 is_enabled: Indicates whether this gallery image is enabled. - :type is_enabled: bool - :param is_override: Indicates whether this gallery has been overridden for this lab account. - :type is_override: bool - :param is_plan_authorized: Indicates if the plan has been authorized for programmatic - deployment. - :type is_plan_authorized: bool - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str + :ivar offer: The image offer if applicable. + :vartype offer: str + :ivar publisher: The image publisher. + :vartype publisher: str + :ivar sku: The image SKU. + :vartype sku: str + :ivar version: The image version specified on creation. + :vartype version: str + :ivar exact_version: The actual version of the image after use. + :vartype exact_version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + 'id': {'max_length': 2000, 'min_length': 3}, + 'exact_version': {'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}'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'is_override': {'key': 'properties.isOverride', 'type': 'bool'}, - '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, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - is_enabled: Optional[bool] = None, - is_override: Optional[bool] = None, - is_plan_authorized: Optional[bool] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, - **kwargs - ): - super(GalleryImageFragment, self).__init__(location=location, tags=tags, **kwargs) - self.is_enabled = is_enabled - self.is_override = is_override - self.is_plan_authorized = is_plan_authorized - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - - -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, - *, - offer: Optional[str] = None, - publisher: Optional[str] = None, - sku: Optional[str] = None, - os_type: Optional[str] = None, - version: Optional[str] = None, - **kwargs - ): - super(GalleryImageReference, self).__init__(**kwargs) - self.offer = offer - self.publisher = publisher - self.sku = sku - self.os_type = os_type - 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'}, + 'exact_version': {'key': 'exactVersion', 'type': 'str'}, } def __init__( self, *, + id: Optional[str] = None, 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) + """ + :keyword id: Image resource ID. + :paramtype id: str + :keyword offer: The image offer if applicable. + :paramtype offer: str + :keyword publisher: The image publisher. + :paramtype publisher: str + :keyword sku: The image SKU. + :paramtype sku: str + :keyword version: The image version specified on creation. + :paramtype version: str + """ + super(ImageReference, self).__init__(**kwargs) + self.id = id self.offer = offer self.publisher = publisher self.sku = sku - self.os_type = os_type self.version = version + self.exact_version = None -class GetEnvironmentResponse(msrest.serialization.Model): - """Represents the environments details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar environment: Details of the environment. - :vartype environment: ~azure.mgmt.labservices.models.EnvironmentDetails - """ - - _validation = { - 'environment': {'readonly': True}, - } - - _attribute_map = { - 'environment': {'key': 'environment', 'type': 'EnvironmentDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(GetEnvironmentResponse, self).__init__(**kwargs) - self.environment = None - - -class GetPersonalPreferencesResponse(msrest.serialization.Model): - """Represents the PersonalPreferences for the user. +class ImageUpdate(msrest.serialization.Model): + """Lab services virtual machine image for updates. - :param id: Id to be used by the cache orchestrator. - :type id: str - :param favorite_lab_resource_ids: Array of favorite lab resource ids. - :type favorite_lab_resource_ids: list[str] + :ivar enabled_state: Is the image enabled. Possible values include: "Enabled", "Disabled". + :vartype enabled_state: str or ~azure.mgmt.labservices.models.EnableState """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'favorite_lab_resource_ids': {'key': 'favoriteLabResourceIds', 'type': '[str]'}, + 'enabled_state': {'key': 'properties.enabledState', 'type': 'str'}, } def __init__( self, *, - id: Optional[str] = None, - favorite_lab_resource_ids: Optional[List[str]] = None, + enabled_state: Optional[Union[str, "EnableState"]] = None, **kwargs ): - super(GetPersonalPreferencesResponse, self).__init__(**kwargs) - self.id = id - self.favorite_lab_resource_ids = favorite_lab_resource_ids + """ + :keyword enabled_state: Is the image enabled. Possible values include: "Enabled", "Disabled". + :paramtype enabled_state: str or ~azure.mgmt.labservices.models.EnableState + """ + super(ImageUpdate, self).__init__(**kwargs) + self.enabled_state = enabled_state -class GetRegionalAvailabilityResponse(msrest.serialization.Model): - """The response model from the GetRegionalAvailability action. +class InviteBody(msrest.serialization.Model): + """Body for a user invite request. - :param regional_availability: Availability information for different size categories per - region. - :type regional_availability: list[~azure.mgmt.labservices.models.RegionalAvailability] + :ivar text: Custom text for the invite email. + :vartype text: str """ _attribute_map = { - 'regional_availability': {'key': 'regionalAvailability', 'type': '[RegionalAvailability]'}, + 'text': {'key': 'text', 'type': 'str'}, } def __init__( self, *, - regional_availability: Optional[List["RegionalAvailability"]] = None, + text: Optional[str] = None, **kwargs ): - super(GetRegionalAvailabilityResponse, self).__init__(**kwargs) - self.regional_availability = regional_availability + """ + :keyword text: Custom text for the invite email. + :paramtype text: str + """ + super(InviteBody, self).__init__(**kwargs) + self.text = text -class Lab(Resource): - """Represents a lab. +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. - :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 max_users_in_lab: Maximum number of users allowed in the lab. - :type max_users_in_lab: int - :ivar user_quota: Maximum value MaxUsersInLab can be set to, as specified by the service. - :vartype user_quota: int - :ivar invitation_code: Invitation code that users can use to join a lab. - :vartype invitation_code: str - :ivar created_by_object_id: Object id of the user that created the lab. - :vartype created_by_object_id: str - :param usage_quota: Maximum duration a user can use an environment for in the lab. - :type usage_quota: ~datetime.timedelta - :param user_access_mode: Lab user access mode (open to all vs. restricted to those listed on - the lab). Possible values include: "Restricted", "Open". - :type user_access_mode: str or ~azure.mgmt.labservices.models.LabUserAccessMode - :ivar created_by_user_principal_name: Lab creator name. - :vartype created_by_user_principal_name: str - :ivar created_date: Creation date for the lab. - :vartype created_date: ~datetime.datetime - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'user_quota': {'readonly': True}, - 'invitation_code': {'readonly': True}, - 'created_by_object_id': {'readonly': True}, - 'created_by_user_principal_name': {'readonly': True}, - 'created_date': {'readonly': True}, - 'latest_operation_result': {'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}'}, - 'max_users_in_lab': {'key': 'properties.maxUsersInLab', 'type': 'int'}, - 'user_quota': {'key': 'properties.userQuota', 'type': 'int'}, - 'invitation_code': {'key': 'properties.invitationCode', 'type': 'str'}, - 'created_by_object_id': {'key': 'properties.createdByObjectId', 'type': 'str'}, - 'usage_quota': {'key': 'properties.usageQuota', 'type': 'duration'}, - 'user_access_mode': {'key': 'properties.userAccessMode', 'type': 'str'}, - 'created_by_user_principal_name': {'key': 'properties.createdByUserPrincipalName', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - max_users_in_lab: Optional[int] = None, - usage_quota: Optional[datetime.timedelta] = None, - user_access_mode: Optional[Union[str, "LabUserAccessMode"]] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, - **kwargs - ): - super(Lab, self).__init__(location=location, tags=tags, **kwargs) - self.max_users_in_lab = max_users_in_lab - self.user_quota = None - self.invitation_code = None - self.created_by_object_id = None - self.usage_quota = usage_quota - self.user_access_mode = user_access_mode - self.created_by_user_principal_name = None - self.created_date = None - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - self.latest_operation_result = None - - -class LabAccount(Resource): - """Represents a lab account. - - Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. - :ivar id: The identifier of the resource. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :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 size_configuration: Represents the size configuration under the lab account. - :vartype size_configuration: ~azure.mgmt.labservices.models.SizeConfigurationProperties - :param enabled_region_selection: Represents if region selection is enabled. - :type enabled_region_selection: bool - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'size_configuration': {'readonly': True}, - 'latest_operation_result': {'readonly': True}, + 'location': {'required': 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}'}, - 'size_configuration': {'key': 'properties.sizeConfiguration', 'type': 'SizeConfigurationProperties'}, - 'enabled_region_selection': {'key': 'properties.enabledRegionSelection', 'type': 'bool'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, + 'location': {'key': 'location', 'type': 'str'}, } def __init__( self, *, - location: Optional[str] = None, + location: str, tags: Optional[Dict[str, str]] = None, - enabled_region_selection: Optional[bool] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, **kwargs ): - super(LabAccount, self).__init__(location=location, tags=tags, **kwargs) - self.size_configuration = None - self.enabled_region_selection = enabled_region_selection - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - self.latest_operation_result = None + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location -class LabAccountFragment(Resource): - """Represents a lab account. +class Lab(TrackedResource): + """The lab resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The identifier of the resource. + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :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 enabled_region_selection: Represents if region selection is enabled. - :type enabled_region_selection: bool - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar system_data: Metadata pertaining to creation and last modification of the lab. + :vartype system_data: ~azure.mgmt.labservices.models.SystemData + :ivar auto_shutdown_profile: The resource auto shutdown configuration for the lab. This + controls whether actions are taken on resources that are sitting idle. + :vartype auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :ivar connection_profile: The connection profile for the lab. This controls settings such as + web access to lab resources or whether RDP or SSH ports are open. + :vartype connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :ivar virtual_machine_profile: The profile used for creating lab virtual machines. + :vartype virtual_machine_profile: ~azure.mgmt.labservices.models.VirtualMachineProfile + :ivar security_profile: The lab security profile. + :vartype security_profile: ~azure.mgmt.labservices.models.SecurityProfile + :ivar roster_profile: The lab user list management profile. + :vartype roster_profile: ~azure.mgmt.labservices.models.RosterProfile + :ivar lab_plan_id: The ID of the lab plan. Used during resource creation to provide defaults + and acts as a permission container when creating a lab via labs.azure.com. Setting a labPlanId + on an existing lab provides organization.. + :vartype lab_plan_id: str + :ivar title: The title of the lab. + :vartype title: str + :ivar description: The description of the lab. + :vartype description: str + :ivar provisioning_state: Current provisioning state of the lab. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState + :ivar network_profile: The network profile for the lab, typically applied via a lab plan. This + profile cannot be modified once a lab has been created. + :vartype network_profile: ~azure.mgmt.labservices.models.LabNetworkProfile + :ivar state: The lab state. Possible values include: "Draft", "Publishing", "Scaling", + "Syncing", "Published". + :vartype state: str or ~azure.mgmt.labservices.models.LabState """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'lab_plan_id': {'max_length': 2000, 'min_length': 3}, + 'title': {'max_length': 120, 'min_length': 1}, + 'provisioning_state': {'readonly': True}, + 'state': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled_region_selection': {'key': 'properties.enabledRegionSelection', 'type': 'bool'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'auto_shutdown_profile': {'key': 'properties.autoShutdownProfile', 'type': 'AutoShutdownProfile'}, + 'connection_profile': {'key': 'properties.connectionProfile', 'type': 'ConnectionProfile'}, + 'virtual_machine_profile': {'key': 'properties.virtualMachineProfile', 'type': 'VirtualMachineProfile'}, + 'security_profile': {'key': 'properties.securityProfile', 'type': 'SecurityProfile'}, + 'roster_profile': {'key': 'properties.rosterProfile', 'type': 'RosterProfile'}, + 'lab_plan_id': {'key': 'properties.labPlanId', 'type': 'str'}, + 'title': {'key': 'properties.title', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, + 'network_profile': {'key': 'properties.networkProfile', 'type': 'LabNetworkProfile'}, + 'state': {'key': 'properties.state', 'type': 'str'}, } def __init__( self, *, - location: Optional[str] = None, + location: str, tags: Optional[Dict[str, str]] = None, - enabled_region_selection: Optional[bool] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, - **kwargs - ): - super(LabAccountFragment, self).__init__(location=location, tags=tags, **kwargs) - self.enabled_region_selection = enabled_region_selection - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - - -class LabCreationParameters(msrest.serialization.Model): - """Settings related to creating a lab. - - :param max_users_in_lab: Maximum number of users allowed in the lab. - :type max_users_in_lab: int - """ - - _attribute_map = { - 'max_users_in_lab': {'key': 'maxUsersInLab', 'type': 'int'}, - } - - def __init__( - self, - *, - max_users_in_lab: Optional[int] = None, - **kwargs - ): - super(LabCreationParameters, self).__init__(**kwargs) - self.max_users_in_lab = max_users_in_lab - + auto_shutdown_profile: Optional["AutoShutdownProfile"] = None, + connection_profile: Optional["ConnectionProfile"] = None, + virtual_machine_profile: Optional["VirtualMachineProfile"] = None, + security_profile: Optional["SecurityProfile"] = None, + roster_profile: Optional["RosterProfile"] = None, + lab_plan_id: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + network_profile: Optional["LabNetworkProfile"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword auto_shutdown_profile: The resource auto shutdown configuration for the lab. This + controls whether actions are taken on resources that are sitting idle. + :paramtype auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :keyword connection_profile: The connection profile for the lab. This controls settings such as + web access to lab resources or whether RDP or SSH ports are open. + :paramtype connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :keyword virtual_machine_profile: The profile used for creating lab virtual machines. + :paramtype virtual_machine_profile: ~azure.mgmt.labservices.models.VirtualMachineProfile + :keyword security_profile: The lab security profile. + :paramtype security_profile: ~azure.mgmt.labservices.models.SecurityProfile + :keyword roster_profile: The lab user list management profile. + :paramtype roster_profile: ~azure.mgmt.labservices.models.RosterProfile + :keyword lab_plan_id: The ID of the lab plan. Used during resource creation to provide defaults + and acts as a permission container when creating a lab via labs.azure.com. Setting a labPlanId + on an existing lab provides organization.. + :paramtype lab_plan_id: str + :keyword title: The title of the lab. + :paramtype title: str + :keyword description: The description of the lab. + :paramtype description: str + :keyword network_profile: The network profile for the lab, typically applied via a lab plan. + This profile cannot be modified once a lab has been created. + :paramtype network_profile: ~azure.mgmt.labservices.models.LabNetworkProfile + """ + super(Lab, self).__init__(tags=tags, location=location, **kwargs) + self.system_data = None + self.auto_shutdown_profile = auto_shutdown_profile + self.connection_profile = connection_profile + self.virtual_machine_profile = virtual_machine_profile + self.security_profile = security_profile + self.roster_profile = roster_profile + self.lab_plan_id = lab_plan_id + self.title = title + self.description = description + self.provisioning_state = None + self.network_profile = network_profile + self.state = None -class LabDetails(msrest.serialization.Model): - """This represents the details about a lab that the User is in, and its state. - Variables are only populated by the server, and will be ignored when sending a request. +class LabNetworkProfile(msrest.serialization.Model): + """Profile for how to handle networking for Labs. - :param name: Name of the lab. - :type name: str - :param provisioning_state: The provisioning state of the lab. - :type provisioning_state: str - :param id: The Id of the lab. - :type id: str - :ivar usage_quota: The maximum duration a user can use a VM in this lab. - :vartype usage_quota: ~datetime.timedelta + :ivar subnet_id: The external subnet resource id. + :vartype subnet_id: str + :ivar load_balancer_id: The external load balancer resource id. + :vartype load_balancer_id: str + :ivar public_ip_id: The external public IP resource id. + :vartype public_ip_id: str """ _validation = { - 'usage_quota': {'readonly': True}, + 'subnet_id': {'max_length': 2000, 'min_length': 3}, + 'load_balancer_id': {'max_length': 2000, 'min_length': 3}, + 'public_ip_id': {'max_length': 2000, 'min_length': 3}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'usage_quota': {'key': 'usageQuota', 'type': 'duration'}, + 'subnet_id': {'key': 'subnetId', 'type': 'str'}, + 'load_balancer_id': {'key': 'loadBalancerId', 'type': 'str'}, + 'public_ip_id': {'key': 'publicIpId', 'type': 'str'}, } def __init__( self, *, - name: Optional[str] = None, - provisioning_state: Optional[str] = None, - id: Optional[str] = None, + subnet_id: Optional[str] = None, + load_balancer_id: Optional[str] = None, + public_ip_id: Optional[str] = None, **kwargs ): - super(LabDetails, self).__init__(**kwargs) - self.name = name - self.provisioning_state = provisioning_state - self.id = id - self.usage_quota = None + """ + :keyword subnet_id: The external subnet resource id. + :paramtype subnet_id: str + :keyword load_balancer_id: The external load balancer resource id. + :paramtype load_balancer_id: str + :keyword public_ip_id: The external public IP resource id. + :paramtype public_ip_id: str + """ + super(LabNetworkProfile, self).__init__(**kwargs) + self.subnet_id = subnet_id + self.load_balancer_id = load_balancer_id + self.public_ip_id = public_ip_id -class LabFragment(Resource): - """Represents a lab. +class LabPlan(TrackedResource): + """Lab Plans act as a permission container for creating labs via labs.azure.com. Additionally, they can provide a set of default configurations that will apply at the time of creating a lab, but these defaults can still be overwritten. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The identifier of the resource. + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :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 max_users_in_lab: Maximum number of users allowed in the lab. - :type max_users_in_lab: int - :param usage_quota: Maximum duration a user can use an environment for in the lab. - :type usage_quota: ~datetime.timedelta - :param user_access_mode: Lab user access mode (open to all vs. restricted to those listed on - the lab). Possible values include: "Restricted", "Open". - :type user_access_mode: str or ~azure.mgmt.labservices.models.LabUserAccessMode - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar system_data: Metadata pertaining to creation and last modification of the lab plan. + :vartype system_data: ~azure.mgmt.labservices.models.SystemData + :ivar default_connection_profile: The default lab connection profile. This can be changed on a + lab resource and only provides a default profile. + :vartype default_connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :ivar default_auto_shutdown_profile: The default lab shutdown profile. This can be changed on a + lab resource and only provides a default profile. + :vartype default_auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :ivar default_network_profile: The lab plan network profile. To enforce lab network policies + they must be defined here and cannot be changed when there are existing labs associated with + this lab plan. + :vartype default_network_profile: ~azure.mgmt.labservices.models.LabPlanNetworkProfile + :ivar allowed_regions: The allowed regions for the lab creator to use when creating labs using + this lab plan. + :vartype allowed_regions: list[str] + :ivar shared_gallery_id: Resource ID of the Shared Image Gallery attached to this lab plan. + When saving a lab template virtual machine image it will be persisted in this gallery. Shared + images from the gallery can be made available to use when creating new labs. + :vartype shared_gallery_id: str + :ivar support_info: Support contact information and instructions for users of the lab plan. + This information is displayed to lab owners and virtual machine users for all labs in the lab + plan. + :vartype support_info: ~azure.mgmt.labservices.models.SupportInfo + :ivar linked_lms_instance: Base Url of the lms instance this lab plan can link lab rosters + against. + :vartype linked_lms_instance: str + :ivar provisioning_state: Current provisioning state of the lab plan. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'shared_gallery_id': {'max_length': 2000, 'min_length': 3}, + 'linked_lms_instance': {'max_length': 2000, 'min_length': 3}, + 'provisioning_state': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'max_users_in_lab': {'key': 'properties.maxUsersInLab', 'type': 'int'}, - 'usage_quota': {'key': 'properties.usageQuota', 'type': 'duration'}, - 'user_access_mode': {'key': 'properties.userAccessMode', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'default_connection_profile': {'key': 'properties.defaultConnectionProfile', 'type': 'ConnectionProfile'}, + 'default_auto_shutdown_profile': {'key': 'properties.defaultAutoShutdownProfile', 'type': 'AutoShutdownProfile'}, + 'default_network_profile': {'key': 'properties.defaultNetworkProfile', 'type': 'LabPlanNetworkProfile'}, + 'allowed_regions': {'key': 'properties.allowedRegions', 'type': '[str]'}, + 'shared_gallery_id': {'key': 'properties.sharedGalleryId', 'type': 'str'}, + 'support_info': {'key': 'properties.supportInfo', 'type': 'SupportInfo'}, + 'linked_lms_instance': {'key': 'properties.linkedLmsInstance', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, } def __init__( self, *, - location: Optional[str] = None, + location: str, tags: Optional[Dict[str, str]] = None, - max_users_in_lab: Optional[int] = None, - usage_quota: Optional[datetime.timedelta] = None, - user_access_mode: Optional[Union[str, "LabUserAccessMode"]] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, - **kwargs - ): - super(LabFragment, self).__init__(location=location, tags=tags, **kwargs) - self.max_users_in_lab = max_users_in_lab - self.usage_quota = usage_quota - self.user_access_mode = user_access_mode - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - + default_connection_profile: Optional["ConnectionProfile"] = None, + default_auto_shutdown_profile: Optional["AutoShutdownProfile"] = None, + default_network_profile: Optional["LabPlanNetworkProfile"] = None, + allowed_regions: Optional[List[str]] = None, + shared_gallery_id: Optional[str] = None, + support_info: Optional["SupportInfo"] = None, + linked_lms_instance: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword default_connection_profile: The default lab connection profile. This can be changed on + a lab resource and only provides a default profile. + :paramtype default_connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :keyword default_auto_shutdown_profile: The default lab shutdown profile. This can be changed + on a lab resource and only provides a default profile. + :paramtype default_auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :keyword default_network_profile: The lab plan network profile. To enforce lab network policies + they must be defined here and cannot be changed when there are existing labs associated with + this lab plan. + :paramtype default_network_profile: ~azure.mgmt.labservices.models.LabPlanNetworkProfile + :keyword allowed_regions: The allowed regions for the lab creator to use when creating labs + using this lab plan. + :paramtype allowed_regions: list[str] + :keyword shared_gallery_id: Resource ID of the Shared Image Gallery attached to this lab plan. + When saving a lab template virtual machine image it will be persisted in this gallery. Shared + images from the gallery can be made available to use when creating new labs. + :paramtype shared_gallery_id: str + :keyword support_info: Support contact information and instructions for users of the lab plan. + This information is displayed to lab owners and virtual machine users for all labs in the lab + plan. + :paramtype support_info: ~azure.mgmt.labservices.models.SupportInfo + :keyword linked_lms_instance: Base Url of the lms instance this lab plan can link lab rosters + against. + :paramtype linked_lms_instance: str + """ + super(LabPlan, self).__init__(tags=tags, location=location, **kwargs) + self.system_data = None + self.default_connection_profile = default_connection_profile + self.default_auto_shutdown_profile = default_auto_shutdown_profile + self.default_network_profile = default_network_profile + self.allowed_regions = allowed_regions + self.shared_gallery_id = shared_gallery_id + self.support_info = support_info + self.linked_lms_instance = linked_lms_instance + self.provisioning_state = None -class LatestOperationResult(msrest.serialization.Model): - """Details of the status of an operation. - Variables are only populated by the server, and will be ignored when sending a request. +class LabPlanNetworkProfile(msrest.serialization.Model): + """Profile for how to handle networking for Lab Plans. - :ivar status: The current status of the operation. - :vartype status: str - :ivar error_code: Error code on failure. - :vartype error_code: str - :ivar error_message: The error message. - :vartype error_message: str - :ivar request_uri: Request URI of the operation. - :vartype request_uri: str - :ivar http_method: The HttpMethod - PUT/POST/DELETE for the operation. - :vartype http_method: str - :ivar operation_url: The URL to use to check long-running operation status. - :vartype operation_url: str + :ivar subnet_id: The external subnet resource id. + :vartype subnet_id: str """ _validation = { - 'status': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'request_uri': {'readonly': True}, - 'http_method': {'readonly': True}, - 'operation_url': {'readonly': True}, + 'subnet_id': {'max_length': 2000, 'min_length': 3}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'http_method': {'key': 'httpMethod', 'type': 'str'}, - 'operation_url': {'key': 'operationUrl', 'type': 'str'}, + 'subnet_id': {'key': 'subnetId', 'type': 'str'}, } def __init__( self, - **kwargs - ): - super(LatestOperationResult, self).__init__(**kwargs) - self.status = None - self.error_code = None - self.error_message = None - self.request_uri = None - self.http_method = None - self.operation_url = None + *, + subnet_id: Optional[str] = None, + **kwargs + ): + """ + :keyword subnet_id: The external subnet resource id. + :paramtype subnet_id: str + """ + super(LabPlanNetworkProfile, self).__init__(**kwargs) + self.subnet_id = subnet_id + + +class LabPlanUpdateProperties(msrest.serialization.Model): + """Lab plan resource properties for updates. + + :ivar default_connection_profile: The default lab connection profile. This can be changed on a + lab resource and only provides a default profile. + :vartype default_connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :ivar default_auto_shutdown_profile: The default lab shutdown profile. This can be changed on a + lab resource and only provides a default profile. + :vartype default_auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :ivar default_network_profile: The lab plan network profile. To enforce lab network policies + they must be defined here and cannot be changed when there are existing labs associated with + this lab plan. + :vartype default_network_profile: ~azure.mgmt.labservices.models.LabPlanNetworkProfile + :ivar allowed_regions: The allowed regions for the lab creator to use when creating labs using + this lab plan. + :vartype allowed_regions: list[str] + :ivar shared_gallery_id: Resource ID of the Shared Image Gallery attached to this lab plan. + When saving a lab template virtual machine image it will be persisted in this gallery. Shared + images from the gallery can be made available to use when creating new labs. + :vartype shared_gallery_id: str + :ivar support_info: Support contact information and instructions for users of the lab plan. + This information is displayed to lab owners and virtual machine users for all labs in the lab + plan. + :vartype support_info: ~azure.mgmt.labservices.models.SupportInfo + :ivar linked_lms_instance: Base Url of the lms instance this lab plan can link lab rosters + against. + :vartype linked_lms_instance: str + """ + _validation = { + 'shared_gallery_id': {'max_length': 2000, 'min_length': 3}, + 'linked_lms_instance': {'max_length': 2000, 'min_length': 3}, + } + + _attribute_map = { + 'default_connection_profile': {'key': 'defaultConnectionProfile', 'type': 'ConnectionProfile'}, + 'default_auto_shutdown_profile': {'key': 'defaultAutoShutdownProfile', 'type': 'AutoShutdownProfile'}, + 'default_network_profile': {'key': 'defaultNetworkProfile', 'type': 'LabPlanNetworkProfile'}, + 'allowed_regions': {'key': 'allowedRegions', 'type': '[str]'}, + 'shared_gallery_id': {'key': 'sharedGalleryId', 'type': 'str'}, + 'support_info': {'key': 'supportInfo', 'type': 'SupportInfo'}, + 'linked_lms_instance': {'key': 'linkedLmsInstance', 'type': 'str'}, + } + + def __init__( + self, + *, + default_connection_profile: Optional["ConnectionProfile"] = None, + default_auto_shutdown_profile: Optional["AutoShutdownProfile"] = None, + default_network_profile: Optional["LabPlanNetworkProfile"] = None, + allowed_regions: Optional[List[str]] = None, + shared_gallery_id: Optional[str] = None, + support_info: Optional["SupportInfo"] = None, + linked_lms_instance: Optional[str] = None, + **kwargs + ): + """ + :keyword default_connection_profile: The default lab connection profile. This can be changed on + a lab resource and only provides a default profile. + :paramtype default_connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :keyword default_auto_shutdown_profile: The default lab shutdown profile. This can be changed + on a lab resource and only provides a default profile. + :paramtype default_auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :keyword default_network_profile: The lab plan network profile. To enforce lab network policies + they must be defined here and cannot be changed when there are existing labs associated with + this lab plan. + :paramtype default_network_profile: ~azure.mgmt.labservices.models.LabPlanNetworkProfile + :keyword allowed_regions: The allowed regions for the lab creator to use when creating labs + using this lab plan. + :paramtype allowed_regions: list[str] + :keyword shared_gallery_id: Resource ID of the Shared Image Gallery attached to this lab plan. + When saving a lab template virtual machine image it will be persisted in this gallery. Shared + images from the gallery can be made available to use when creating new labs. + :paramtype shared_gallery_id: str + :keyword support_info: Support contact information and instructions for users of the lab plan. + This information is displayed to lab owners and virtual machine users for all labs in the lab + plan. + :paramtype support_info: ~azure.mgmt.labservices.models.SupportInfo + :keyword linked_lms_instance: Base Url of the lms instance this lab plan can link lab rosters + against. + :paramtype linked_lms_instance: str + """ + super(LabPlanUpdateProperties, self).__init__(**kwargs) + self.default_connection_profile = default_connection_profile + self.default_auto_shutdown_profile = default_auto_shutdown_profile + self.default_network_profile = default_network_profile + self.allowed_regions = allowed_regions + self.shared_gallery_id = shared_gallery_id + self.support_info = support_info + self.linked_lms_instance = linked_lms_instance + + +class LabPlanProperties(LabPlanUpdateProperties): + """Lab plan resource properties. -class ListEnvironmentsPayload(msrest.serialization.Model): - """Represents the payload to list environments owned by a user. + Variables are only populated by the server, and will be ignored when sending a request. - :param lab_id: The resource Id of the lab. - :type lab_id: str + :ivar default_connection_profile: The default lab connection profile. This can be changed on a + lab resource and only provides a default profile. + :vartype default_connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :ivar default_auto_shutdown_profile: The default lab shutdown profile. This can be changed on a + lab resource and only provides a default profile. + :vartype default_auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :ivar default_network_profile: The lab plan network profile. To enforce lab network policies + they must be defined here and cannot be changed when there are existing labs associated with + this lab plan. + :vartype default_network_profile: ~azure.mgmt.labservices.models.LabPlanNetworkProfile + :ivar allowed_regions: The allowed regions for the lab creator to use when creating labs using + this lab plan. + :vartype allowed_regions: list[str] + :ivar shared_gallery_id: Resource ID of the Shared Image Gallery attached to this lab plan. + When saving a lab template virtual machine image it will be persisted in this gallery. Shared + images from the gallery can be made available to use when creating new labs. + :vartype shared_gallery_id: str + :ivar support_info: Support contact information and instructions for users of the lab plan. + This information is displayed to lab owners and virtual machine users for all labs in the lab + plan. + :vartype support_info: ~azure.mgmt.labservices.models.SupportInfo + :ivar linked_lms_instance: Base Url of the lms instance this lab plan can link lab rosters + against. + :vartype linked_lms_instance: str + :ivar provisioning_state: Current provisioning state of the lab plan. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState """ + _validation = { + 'shared_gallery_id': {'max_length': 2000, 'min_length': 3}, + 'linked_lms_instance': {'max_length': 2000, 'min_length': 3}, + 'provisioning_state': {'readonly': True}, + } + _attribute_map = { - 'lab_id': {'key': 'labId', 'type': 'str'}, + 'default_connection_profile': {'key': 'defaultConnectionProfile', 'type': 'ConnectionProfile'}, + 'default_auto_shutdown_profile': {'key': 'defaultAutoShutdownProfile', 'type': 'AutoShutdownProfile'}, + 'default_network_profile': {'key': 'defaultNetworkProfile', 'type': 'LabPlanNetworkProfile'}, + 'allowed_regions': {'key': 'allowedRegions', 'type': '[str]'}, + 'shared_gallery_id': {'key': 'sharedGalleryId', 'type': 'str'}, + 'support_info': {'key': 'supportInfo', 'type': 'SupportInfo'}, + 'linked_lms_instance': {'key': 'linkedLmsInstance', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } def __init__( self, *, - lab_id: Optional[str] = None, - **kwargs - ): - super(ListEnvironmentsPayload, self).__init__(**kwargs) - self.lab_id = lab_id + default_connection_profile: Optional["ConnectionProfile"] = None, + default_auto_shutdown_profile: Optional["AutoShutdownProfile"] = None, + default_network_profile: Optional["LabPlanNetworkProfile"] = None, + allowed_regions: Optional[List[str]] = None, + shared_gallery_id: Optional[str] = None, + support_info: Optional["SupportInfo"] = None, + linked_lms_instance: Optional[str] = None, + **kwargs + ): + """ + :keyword default_connection_profile: The default lab connection profile. This can be changed on + a lab resource and only provides a default profile. + :paramtype default_connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :keyword default_auto_shutdown_profile: The default lab shutdown profile. This can be changed + on a lab resource and only provides a default profile. + :paramtype default_auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :keyword default_network_profile: The lab plan network profile. To enforce lab network policies + they must be defined here and cannot be changed when there are existing labs associated with + this lab plan. + :paramtype default_network_profile: ~azure.mgmt.labservices.models.LabPlanNetworkProfile + :keyword allowed_regions: The allowed regions for the lab creator to use when creating labs + using this lab plan. + :paramtype allowed_regions: list[str] + :keyword shared_gallery_id: Resource ID of the Shared Image Gallery attached to this lab plan. + When saving a lab template virtual machine image it will be persisted in this gallery. Shared + images from the gallery can be made available to use when creating new labs. + :paramtype shared_gallery_id: str + :keyword support_info: Support contact information and instructions for users of the lab plan. + This information is displayed to lab owners and virtual machine users for all labs in the lab + plan. + :paramtype support_info: ~azure.mgmt.labservices.models.SupportInfo + :keyword linked_lms_instance: Base Url of the lms instance this lab plan can link lab rosters + against. + :paramtype linked_lms_instance: str + """ + super(LabPlanProperties, self).__init__(default_connection_profile=default_connection_profile, default_auto_shutdown_profile=default_auto_shutdown_profile, default_network_profile=default_network_profile, allowed_regions=allowed_regions, shared_gallery_id=shared_gallery_id, support_info=support_info, linked_lms_instance=linked_lms_instance, **kwargs) + self.provisioning_state = None -class ListEnvironmentsResponse(msrest.serialization.Model): - """Represents the list of environments owned by a user. +class TrackedResourceUpdate(msrest.serialization.Model): + """Base tracked resource type for all PATCH updates. - :param environments: List of all the environments. - :type environments: list[~azure.mgmt.labservices.models.EnvironmentDetails] + :ivar tags: A set of tags. Resource tags. + :vartype tags: list[str] """ _attribute_map = { - 'environments': {'key': 'environments', 'type': '[EnvironmentDetails]'}, + 'tags': {'key': 'tags', 'type': '[str]'}, } def __init__( self, *, - environments: Optional[List["EnvironmentDetails"]] = None, + tags: Optional[List[str]] = None, **kwargs ): - super(ListEnvironmentsResponse, self).__init__(**kwargs) - self.environments = environments + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: list[str] + """ + super(TrackedResourceUpdate, self).__init__(**kwargs) + self.tags = tags + +class LabPlanUpdate(TrackedResourceUpdate): + """Contains lab configuration and default settings. This variant is used for PATCH. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: list[str] + :ivar default_connection_profile: The default lab connection profile. This can be changed on a + lab resource and only provides a default profile. + :vartype default_connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :ivar default_auto_shutdown_profile: The default lab shutdown profile. This can be changed on a + lab resource and only provides a default profile. + :vartype default_auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :ivar default_network_profile: The lab plan network profile. To enforce lab network policies + they must be defined here and cannot be changed when there are existing labs associated with + this lab plan. + :vartype default_network_profile: ~azure.mgmt.labservices.models.LabPlanNetworkProfile + :ivar allowed_regions: The allowed regions for the lab creator to use when creating labs using + this lab plan. + :vartype allowed_regions: list[str] + :ivar shared_gallery_id: Resource ID of the Shared Image Gallery attached to this lab plan. + When saving a lab template virtual machine image it will be persisted in this gallery. Shared + images from the gallery can be made available to use when creating new labs. + :vartype shared_gallery_id: str + :ivar support_info: Support contact information and instructions for users of the lab plan. + This information is displayed to lab owners and virtual machine users for all labs in the lab + plan. + :vartype support_info: ~azure.mgmt.labservices.models.SupportInfo + :ivar linked_lms_instance: Base Url of the lms instance this lab plan can link lab rosters + against. + :vartype linked_lms_instance: str + """ + + _validation = { + 'shared_gallery_id': {'max_length': 2000, 'min_length': 3}, + 'linked_lms_instance': {'max_length': 2000, 'min_length': 3}, + } -class ListLabsResponse(msrest.serialization.Model): - """Lists the labs owned by a user. + _attribute_map = { + 'tags': {'key': 'tags', 'type': '[str]'}, + 'default_connection_profile': {'key': 'properties.defaultConnectionProfile', 'type': 'ConnectionProfile'}, + 'default_auto_shutdown_profile': {'key': 'properties.defaultAutoShutdownProfile', 'type': 'AutoShutdownProfile'}, + 'default_network_profile': {'key': 'properties.defaultNetworkProfile', 'type': 'LabPlanNetworkProfile'}, + 'allowed_regions': {'key': 'properties.allowedRegions', 'type': '[str]'}, + 'shared_gallery_id': {'key': 'properties.sharedGalleryId', 'type': 'str'}, + 'support_info': {'key': 'properties.supportInfo', 'type': 'SupportInfo'}, + 'linked_lms_instance': {'key': 'properties.linkedLmsInstance', 'type': 'str'}, + } - :param labs: List of all the labs. - :type labs: list[~azure.mgmt.labservices.models.LabDetails] + def __init__( + self, + *, + tags: Optional[List[str]] = None, + default_connection_profile: Optional["ConnectionProfile"] = None, + default_auto_shutdown_profile: Optional["AutoShutdownProfile"] = None, + default_network_profile: Optional["LabPlanNetworkProfile"] = None, + allowed_regions: Optional[List[str]] = None, + shared_gallery_id: Optional[str] = None, + support_info: Optional["SupportInfo"] = None, + linked_lms_instance: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: list[str] + :keyword default_connection_profile: The default lab connection profile. This can be changed on + a lab resource and only provides a default profile. + :paramtype default_connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :keyword default_auto_shutdown_profile: The default lab shutdown profile. This can be changed + on a lab resource and only provides a default profile. + :paramtype default_auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :keyword default_network_profile: The lab plan network profile. To enforce lab network policies + they must be defined here and cannot be changed when there are existing labs associated with + this lab plan. + :paramtype default_network_profile: ~azure.mgmt.labservices.models.LabPlanNetworkProfile + :keyword allowed_regions: The allowed regions for the lab creator to use when creating labs + using this lab plan. + :paramtype allowed_regions: list[str] + :keyword shared_gallery_id: Resource ID of the Shared Image Gallery attached to this lab plan. + When saving a lab template virtual machine image it will be persisted in this gallery. Shared + images from the gallery can be made available to use when creating new labs. + :paramtype shared_gallery_id: str + :keyword support_info: Support contact information and instructions for users of the lab plan. + This information is displayed to lab owners and virtual machine users for all labs in the lab + plan. + :paramtype support_info: ~azure.mgmt.labservices.models.SupportInfo + :keyword linked_lms_instance: Base Url of the lms instance this lab plan can link lab rosters + against. + :paramtype linked_lms_instance: str + """ + super(LabPlanUpdate, self).__init__(tags=tags, **kwargs) + self.default_connection_profile = default_connection_profile + self.default_auto_shutdown_profile = default_auto_shutdown_profile + self.default_network_profile = default_network_profile + self.allowed_regions = allowed_regions + self.shared_gallery_id = shared_gallery_id + self.support_info = support_info + self.linked_lms_instance = linked_lms_instance + + +class LabUpdateProperties(msrest.serialization.Model): + """Properties of a lab resource used for updates. + + :ivar auto_shutdown_profile: The resource auto shutdown configuration for the lab. This + controls whether actions are taken on resources that are sitting idle. + :vartype auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :ivar connection_profile: The connection profile for the lab. This controls settings such as + web access to lab resources or whether RDP or SSH ports are open. + :vartype connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :ivar virtual_machine_profile: The profile used for creating lab virtual machines. + :vartype virtual_machine_profile: ~azure.mgmt.labservices.models.VirtualMachineProfile + :ivar security_profile: The lab security profile. + :vartype security_profile: ~azure.mgmt.labservices.models.SecurityProfile + :ivar roster_profile: The lab user list management profile. + :vartype roster_profile: ~azure.mgmt.labservices.models.RosterProfile + :ivar lab_plan_id: The ID of the lab plan. Used during resource creation to provide defaults + and acts as a permission container when creating a lab via labs.azure.com. Setting a labPlanId + on an existing lab provides organization.. + :vartype lab_plan_id: str + :ivar title: The title of the lab. + :vartype title: str + :ivar description: The description of the lab. + :vartype description: str """ + _validation = { + 'lab_plan_id': {'max_length': 2000, 'min_length': 3}, + 'title': {'max_length': 120, 'min_length': 1}, + } + _attribute_map = { - 'labs': {'key': 'labs', 'type': '[LabDetails]'}, + 'auto_shutdown_profile': {'key': 'autoShutdownProfile', 'type': 'AutoShutdownProfile'}, + 'connection_profile': {'key': 'connectionProfile', 'type': 'ConnectionProfile'}, + 'virtual_machine_profile': {'key': 'virtualMachineProfile', 'type': 'VirtualMachineProfile'}, + 'security_profile': {'key': 'securityProfile', 'type': 'SecurityProfile'}, + 'roster_profile': {'key': 'rosterProfile', 'type': 'RosterProfile'}, + 'lab_plan_id': {'key': 'labPlanId', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, } def __init__( self, *, - labs: Optional[List["LabDetails"]] = None, + auto_shutdown_profile: Optional["AutoShutdownProfile"] = None, + connection_profile: Optional["ConnectionProfile"] = None, + virtual_machine_profile: Optional["VirtualMachineProfile"] = None, + security_profile: Optional["SecurityProfile"] = None, + roster_profile: Optional["RosterProfile"] = None, + lab_plan_id: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, **kwargs ): - super(ListLabsResponse, self).__init__(**kwargs) - self.labs = labs + """ + :keyword auto_shutdown_profile: The resource auto shutdown configuration for the lab. This + controls whether actions are taken on resources that are sitting idle. + :paramtype auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :keyword connection_profile: The connection profile for the lab. This controls settings such as + web access to lab resources or whether RDP or SSH ports are open. + :paramtype connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :keyword virtual_machine_profile: The profile used for creating lab virtual machines. + :paramtype virtual_machine_profile: ~azure.mgmt.labservices.models.VirtualMachineProfile + :keyword security_profile: The lab security profile. + :paramtype security_profile: ~azure.mgmt.labservices.models.SecurityProfile + :keyword roster_profile: The lab user list management profile. + :paramtype roster_profile: ~azure.mgmt.labservices.models.RosterProfile + :keyword lab_plan_id: The ID of the lab plan. Used during resource creation to provide defaults + and acts as a permission container when creating a lab via labs.azure.com. Setting a labPlanId + on an existing lab provides organization.. + :paramtype lab_plan_id: str + :keyword title: The title of the lab. + :paramtype title: str + :keyword description: The description of the lab. + :paramtype description: str + """ + super(LabUpdateProperties, self).__init__(**kwargs) + self.auto_shutdown_profile = auto_shutdown_profile + self.connection_profile = connection_profile + self.virtual_machine_profile = virtual_machine_profile + self.security_profile = security_profile + self.roster_profile = roster_profile + self.lab_plan_id = lab_plan_id + self.title = title + self.description = description -class NetworkInterface(msrest.serialization.Model): - """Network details of the environment. +class LabProperties(LabUpdateProperties): + """Properties of a lab resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar private_ip_address: PrivateIp address of the Compute VM. - :vartype private_ip_address: str - :ivar ssh_authority: Connection information for Linux. - :vartype ssh_authority: str - :ivar rdp_authority: Connection information for Windows. - :vartype rdp_authority: str - :ivar username: Username of the VM. - :vartype username: str + :ivar auto_shutdown_profile: The resource auto shutdown configuration for the lab. This + controls whether actions are taken on resources that are sitting idle. + :vartype auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :ivar connection_profile: The connection profile for the lab. This controls settings such as + web access to lab resources or whether RDP or SSH ports are open. + :vartype connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :ivar virtual_machine_profile: The profile used for creating lab virtual machines. + :vartype virtual_machine_profile: ~azure.mgmt.labservices.models.VirtualMachineProfile + :ivar security_profile: The lab security profile. + :vartype security_profile: ~azure.mgmt.labservices.models.SecurityProfile + :ivar roster_profile: The lab user list management profile. + :vartype roster_profile: ~azure.mgmt.labservices.models.RosterProfile + :ivar lab_plan_id: The ID of the lab plan. Used during resource creation to provide defaults + and acts as a permission container when creating a lab via labs.azure.com. Setting a labPlanId + on an existing lab provides organization.. + :vartype lab_plan_id: str + :ivar title: The title of the lab. + :vartype title: str + :ivar description: The description of the lab. + :vartype description: str + :ivar provisioning_state: Current provisioning state of the lab. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState + :ivar network_profile: The network profile for the lab, typically applied via a lab plan. This + profile cannot be modified once a lab has been created. + :vartype network_profile: ~azure.mgmt.labservices.models.LabNetworkProfile + :ivar state: The lab state. Possible values include: "Draft", "Publishing", "Scaling", + "Syncing", "Published". + :vartype state: str or ~azure.mgmt.labservices.models.LabState """ _validation = { - 'private_ip_address': {'readonly': True}, - 'ssh_authority': {'readonly': True}, - 'rdp_authority': {'readonly': True}, - 'username': {'readonly': True}, + 'lab_plan_id': {'max_length': 2000, 'min_length': 3}, + 'title': {'max_length': 120, 'min_length': 1}, + 'provisioning_state': {'readonly': True}, + 'state': {'readonly': True}, } _attribute_map = { - 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, + 'auto_shutdown_profile': {'key': 'autoShutdownProfile', 'type': 'AutoShutdownProfile'}, + 'connection_profile': {'key': 'connectionProfile', 'type': 'ConnectionProfile'}, + 'virtual_machine_profile': {'key': 'virtualMachineProfile', 'type': 'VirtualMachineProfile'}, + 'security_profile': {'key': 'securityProfile', 'type': 'SecurityProfile'}, + 'roster_profile': {'key': 'rosterProfile', 'type': 'RosterProfile'}, + 'lab_plan_id': {'key': 'labPlanId', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'network_profile': {'key': 'networkProfile', 'type': 'LabNetworkProfile'}, + 'state': {'key': 'state', 'type': 'str'}, } def __init__( self, - **kwargs - ): - super(NetworkInterface, self).__init__(**kwargs) - self.private_ip_address = None - self.ssh_authority = None - self.rdp_authority = None - self.username = None + *, + auto_shutdown_profile: Optional["AutoShutdownProfile"] = None, + connection_profile: Optional["ConnectionProfile"] = None, + virtual_machine_profile: Optional["VirtualMachineProfile"] = None, + security_profile: Optional["SecurityProfile"] = None, + roster_profile: Optional["RosterProfile"] = None, + lab_plan_id: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + network_profile: Optional["LabNetworkProfile"] = None, + **kwargs + ): + """ + :keyword auto_shutdown_profile: The resource auto shutdown configuration for the lab. This + controls whether actions are taken on resources that are sitting idle. + :paramtype auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :keyword connection_profile: The connection profile for the lab. This controls settings such as + web access to lab resources or whether RDP or SSH ports are open. + :paramtype connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :keyword virtual_machine_profile: The profile used for creating lab virtual machines. + :paramtype virtual_machine_profile: ~azure.mgmt.labservices.models.VirtualMachineProfile + :keyword security_profile: The lab security profile. + :paramtype security_profile: ~azure.mgmt.labservices.models.SecurityProfile + :keyword roster_profile: The lab user list management profile. + :paramtype roster_profile: ~azure.mgmt.labservices.models.RosterProfile + :keyword lab_plan_id: The ID of the lab plan. Used during resource creation to provide defaults + and acts as a permission container when creating a lab via labs.azure.com. Setting a labPlanId + on an existing lab provides organization.. + :paramtype lab_plan_id: str + :keyword title: The title of the lab. + :paramtype title: str + :keyword description: The description of the lab. + :paramtype description: str + :keyword network_profile: The network profile for the lab, typically applied via a lab plan. + This profile cannot be modified once a lab has been created. + :paramtype network_profile: ~azure.mgmt.labservices.models.LabNetworkProfile + """ + super(LabProperties, self).__init__(auto_shutdown_profile=auto_shutdown_profile, connection_profile=connection_profile, virtual_machine_profile=virtual_machine_profile, security_profile=security_profile, roster_profile=roster_profile, lab_plan_id=lab_plan_id, title=title, description=description, **kwargs) + self.provisioning_state = None + self.network_profile = network_profile + self.state = None -class OperationBatchStatusPayload(msrest.serialization.Model): - """Payload to get the status of an operation. +class LabServicesSku(msrest.serialization.Model): + """Azure Lab Services resource SKUs. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param urls: Required. The operation url of long running operation. - :type urls: list[str] + :ivar resource_type: The lab services resource type. + :vartype resource_type: str + :ivar name: The name of the SKU. + :vartype name: str + :ivar tier: The tier of the SKU. Possible values include: "Standard", "Premium". + :vartype tier: str or ~azure.mgmt.labservices.models.LabServicesSkuTier + :ivar size: The SKU size. + :vartype size: str + :ivar family: The family of the SKU. + :vartype family: str + :ivar capacity: The scale out/in options of the SKU. + :vartype capacity: ~azure.mgmt.labservices.models.LabServicesSkuCapacity + :ivar capabilities: The capabilities of the SKU. + :vartype capabilities: list[~azure.mgmt.labservices.models.LabServicesSkuCapabilities] + :ivar locations: List of locations that are available for a size. + :vartype locations: list[str] + :ivar costs: Metadata for retrieving price info of a lab services SKUs. + :vartype costs: list[~azure.mgmt.labservices.models.LabServicesSkuCost] + :ivar restrictions: Restrictions of a lab services SKUs. + :vartype restrictions: list[~azure.mgmt.labservices.models.LabServicesSkuRestrictions] """ _validation = { - 'urls': {'required': True}, + 'resource_type': {'readonly': True}, + 'name': {'readonly': True}, + 'tier': {'readonly': True}, + 'size': {'readonly': True}, + 'family': {'readonly': True}, + 'capabilities': {'readonly': True}, + 'locations': {'readonly': True}, + 'costs': {'readonly': True}, + 'restrictions': {'readonly': True}, } _attribute_map = { - 'urls': {'key': 'urls', 'type': '[str]'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'LabServicesSkuCapacity'}, + 'capabilities': {'key': 'capabilities', 'type': '[LabServicesSkuCapabilities]'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'costs': {'key': 'costs', 'type': '[LabServicesSkuCost]'}, + 'restrictions': {'key': 'restrictions', 'type': '[LabServicesSkuRestrictions]'}, } def __init__( self, *, - urls: List[str], + capacity: Optional["LabServicesSkuCapacity"] = None, **kwargs ): - super(OperationBatchStatusPayload, self).__init__(**kwargs) - self.urls = urls + """ + :keyword capacity: The scale out/in options of the SKU. + :paramtype capacity: ~azure.mgmt.labservices.models.LabServicesSkuCapacity + """ + super(LabServicesSku, self).__init__(**kwargs) + self.resource_type = None + self.name = None + self.tier = None + self.size = None + self.family = None + self.capacity = capacity + self.capabilities = None + self.locations = None + self.costs = None + self.restrictions = None -class OperationBatchStatusResponse(msrest.serialization.Model): - """Status Details of the long running operation for an environment. +class LabServicesSkuCapabilities(msrest.serialization.Model): + """The array of capabilities of a lab services SKU. Variables are only populated by the server, and will be ignored when sending a request. - :ivar items: Gets a collection of items that contain the operation url and status. - :vartype items: list[~azure.mgmt.labservices.models.OperationBatchStatusResponseItem] + :ivar name: The name of the capability for a SKU. + :vartype name: str + :ivar value: The value of the capability for a SKU. + :vartype value: str """ _validation = { - 'items': {'readonly': True}, + 'name': {'readonly': True}, + 'value': {'readonly': True}, } _attribute_map = { - 'items': {'key': 'items', 'type': '[OperationBatchStatusResponseItem]'}, + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, } def __init__( self, **kwargs ): - super(OperationBatchStatusResponse, self).__init__(**kwargs) - self.items = None + """ + """ + super(LabServicesSkuCapabilities, self).__init__(**kwargs) + self.name = None + self.value = None -class OperationBatchStatusResponseItem(msrest.serialization.Model): - """Represents the status of an operation that used the batch API. +class LabServicesSkuCapacity(msrest.serialization.Model): + """The scale out/in options of the SKU. Variables are only populated by the server, and will be ignored when sending a request. - :ivar operation_url: status of the long running operation for an environment. - :vartype operation_url: str - :ivar status: status of the long running operation for an environment. - :vartype status: str + :ivar default: The default capacity for this resource. + :vartype default: long + :ivar minimum: The lowest permitted capacity for this resource. + :vartype minimum: long + :ivar maximum: The highest permitted capacity for this resource. + :vartype maximum: long + :ivar scale_type: The localized name of the resource. Possible values include: "None", + "Manual", "Automatic". + :vartype scale_type: str or ~azure.mgmt.labservices.models.ScaleType """ _validation = { - 'operation_url': {'readonly': True}, - 'status': {'readonly': True}, + 'default': {'readonly': True}, + 'minimum': {'readonly': True}, + 'maximum': {'readonly': True}, + 'scale_type': {'readonly': True}, } _attribute_map = { - 'operation_url': {'key': 'operationUrl', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + 'default': {'key': 'default', 'type': 'long'}, + 'minimum': {'key': 'minimum', 'type': 'long'}, + 'maximum': {'key': 'maximum', 'type': 'long'}, + 'scale_type': {'key': 'scaleType', 'type': 'str'}, } def __init__( self, **kwargs ): - super(OperationBatchStatusResponseItem, self).__init__(**kwargs) - self.operation_url = None - self.status = None + """ + """ + super(LabServicesSkuCapacity, self).__init__(**kwargs) + self.default = None + self.minimum = None + self.maximum = None + self.scale_type = None -class OperationError(msrest.serialization.Model): - """Error details for the operation in case of a failure. +class LabServicesSkuCost(msrest.serialization.Model): + """The array of costs of a lab services SKU. + + Variables are only populated by the server, and will be ignored when sending a request. - :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 meter_id: The meter id. + :vartype meter_id: str + :ivar quantity: The quantity of units charged. + :vartype quantity: float + :ivar extended_unit: The extended unit. + :vartype extended_unit: str """ + _validation = { + 'meter_id': {'readonly': True}, + 'quantity': {'readonly': True}, + 'extended_unit': {'readonly': True}, + } + _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'float'}, + 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, } def __init__( self, - *, - code: Optional[str] = None, - message: Optional[str] = None, **kwargs ): - super(OperationError, self).__init__(**kwargs) - self.code = code - self.message = message + """ + """ + super(LabServicesSkuCost, self).__init__(**kwargs) + self.meter_id = None + self.quantity = None + self.extended_unit = None -class OperationMetadata(msrest.serialization.Model): - """The REST API operation supported by ManagedLab ResourceProvider. +class LabServicesSkuRestrictions(msrest.serialization.Model): + """The restriction details. + + Variables are only populated by the server, and will be ignored when sending a request. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that describes the operations. - :type display: ~azure.mgmt.labservices.models.OperationMetadataDisplay + :ivar type: The type of restriction. Possible values include: "Location". + :vartype type: str or ~azure.mgmt.labservices.models.RestrictionType + :ivar values: The values of the restriction. + :vartype values: list[str] + :ivar reason_code: The reason for the restriction. Possible values include: "QuotaId", + "NotAvailableForSubscription". + :vartype reason_code: str or ~azure.mgmt.labservices.models.RestrictionReasonCode """ + _validation = { + 'type': {'readonly': True}, + 'values': {'readonly': True}, + 'reason_code': {'readonly': True}, + } + _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationMetadataDisplay'}, + 'type': {'key': 'type', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + 'reason_code': {'key': 'reasonCode', 'type': 'str'}, } def __init__( self, - *, - name: Optional[str] = None, - display: Optional["OperationMetadataDisplay"] = None, **kwargs ): - super(OperationMetadata, self).__init__(**kwargs) - self.name = name - self.display = display - - -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 + """ + """ + super(LabServicesSkuRestrictions, self).__init__(**kwargs) + self.type = None + self.values = None + self.reason_code = None + + +class LabUpdate(TrackedResourceUpdate): + """The lab resource for updates. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: list[str] + :ivar auto_shutdown_profile: The resource auto shutdown configuration for the lab. This + controls whether actions are taken on resources that are sitting idle. + :vartype auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :ivar connection_profile: The connection profile for the lab. This controls settings such as + web access to lab resources or whether RDP or SSH ports are open. + :vartype connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :ivar virtual_machine_profile: The profile used for creating lab virtual machines. + :vartype virtual_machine_profile: ~azure.mgmt.labservices.models.VirtualMachineProfile + :ivar security_profile: The lab security profile. + :vartype security_profile: ~azure.mgmt.labservices.models.SecurityProfile + :ivar roster_profile: The lab user list management profile. + :vartype roster_profile: ~azure.mgmt.labservices.models.RosterProfile + :ivar lab_plan_id: The ID of the lab plan. Used during resource creation to provide defaults + and acts as a permission container when creating a lab via labs.azure.com. Setting a labPlanId + on an existing lab provides organization.. + :vartype lab_plan_id: str + :ivar title: The title of the lab. + :vartype title: str + :ivar description: The description of the lab. + :vartype description: str """ + _validation = { + 'lab_plan_id': {'max_length': 2000, 'min_length': 3}, + 'title': {'max_length': 120, 'min_length': 1}, + } + _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '[str]'}, + 'auto_shutdown_profile': {'key': 'properties.autoShutdownProfile', 'type': 'AutoShutdownProfile'}, + 'connection_profile': {'key': 'properties.connectionProfile', 'type': 'ConnectionProfile'}, + 'virtual_machine_profile': {'key': 'properties.virtualMachineProfile', 'type': 'VirtualMachineProfile'}, + 'security_profile': {'key': 'properties.securityProfile', 'type': 'SecurityProfile'}, + 'roster_profile': {'key': 'properties.rosterProfile', 'type': 'RosterProfile'}, + 'lab_plan_id': {'key': 'properties.labPlanId', 'type': 'str'}, + 'title': {'key': 'properties.title', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, } def __init__( self, *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, + tags: Optional[List[str]] = None, + auto_shutdown_profile: Optional["AutoShutdownProfile"] = None, + connection_profile: Optional["ConnectionProfile"] = None, + virtual_machine_profile: Optional["VirtualMachineProfile"] = None, + security_profile: Optional["SecurityProfile"] = None, + roster_profile: Optional["RosterProfile"] = None, + lab_plan_id: Optional[str] = None, + title: Optional[str] = None, description: Optional[str] = None, **kwargs ): - super(OperationMetadataDisplay, self).__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: list[str] + :keyword auto_shutdown_profile: The resource auto shutdown configuration for the lab. This + controls whether actions are taken on resources that are sitting idle. + :paramtype auto_shutdown_profile: ~azure.mgmt.labservices.models.AutoShutdownProfile + :keyword connection_profile: The connection profile for the lab. This controls settings such as + web access to lab resources or whether RDP or SSH ports are open. + :paramtype connection_profile: ~azure.mgmt.labservices.models.ConnectionProfile + :keyword virtual_machine_profile: The profile used for creating lab virtual machines. + :paramtype virtual_machine_profile: ~azure.mgmt.labservices.models.VirtualMachineProfile + :keyword security_profile: The lab security profile. + :paramtype security_profile: ~azure.mgmt.labservices.models.SecurityProfile + :keyword roster_profile: The lab user list management profile. + :paramtype roster_profile: ~azure.mgmt.labservices.models.RosterProfile + :keyword lab_plan_id: The ID of the lab plan. Used during resource creation to provide defaults + and acts as a permission container when creating a lab via labs.azure.com. Setting a labPlanId + on an existing lab provides organization.. + :paramtype lab_plan_id: str + :keyword title: The title of the lab. + :paramtype title: str + :keyword description: The description of the lab. + :paramtype description: str + """ + super(LabUpdate, self).__init__(tags=tags, **kwargs) + self.auto_shutdown_profile = auto_shutdown_profile + self.connection_profile = connection_profile + self.virtual_machine_profile = virtual_machine_profile + self.security_profile = security_profile + self.roster_profile = roster_profile + self.lab_plan_id = lab_plan_id + self.title = title self.description = description -class OperationResult(msrest.serialization.Model): - """An Operation Result. +class ListUsagesResult(msrest.serialization.Model): + """List of Core Usages. + + Variables are only populated by the server, and will be ignored when sending a request. - :param status: The operation status. - :type status: str - :param error: Error details for the operation in case of a failure. - :type error: ~azure.mgmt.labservices.models.OperationError + :ivar value: The array page of Usages. + :vartype value: list[~azure.mgmt.labservices.models.Usage] + :ivar next_link: The link to get the next page of Usage result. + :vartype next_link: str """ + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'OperationError'}, + 'value': {'key': 'value', 'type': '[Usage]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - status: Optional[str] = None, - error: Optional["OperationError"] = None, **kwargs ): - super(OperationResult, self).__init__(**kwargs) - self.status = status - self.error = error + """ + """ + super(ListUsagesResult, self).__init__(**kwargs) + self.value = None + self.next_link = None -class OperationStatusPayload(msrest.serialization.Model): - """Payload to get the status of an operation. +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param operation_url: Required. The operation url of long running operation. - :type operation_url: str + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.labservices.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~azure.mgmt.labservices.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~azure.mgmt.labservices.models.ActionType """ _validation = { - 'operation_url': {'required': True}, + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, } _attribute_map = { - 'operation_url': {'key': 'operationUrl', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, } def __init__( self, *, - operation_url: str, + display: Optional["OperationDisplay"] = None, **kwargs ): - super(OperationStatusPayload, self).__init__(**kwargs) - self.operation_url = operation_url + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.labservices.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None -class OperationStatusResponse(msrest.serialization.Model): - """Status Details of the long running operation for an environment. +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: status of the long running operation for an environment. - :vartype status: str + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str """ _validation = { - 'status': {'readonly': True}, + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + '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(OperationStatusResponse, self).__init__(**kwargs) - self.status = None + """ + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None -class PersonalPreferencesOperationsPayload(msrest.serialization.Model): - """Represents payload for any Environment operations like get, start, stop, connect. +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. - :param lab_account_resource_id: Resource Id of the lab account. - :type lab_account_resource_id: str - :param add_remove: Enum indicating if user is adding or removing a favorite lab. Possible - values include: "Add", "Remove". - :type add_remove: str or ~azure.mgmt.labservices.models.AddRemove - :param lab_resource_id: Resource Id of the lab to add/remove from the favorites list. - :type lab_resource_id: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.labservices.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str """ + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'lab_account_resource_id': {'key': 'labAccountResourceId', 'type': 'str'}, - 'add_remove': {'key': 'addRemove', 'type': 'str'}, - 'lab_resource_id': {'key': 'labResourceId', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - lab_account_resource_id: Optional[str] = None, - add_remove: Optional[Union[str, "AddRemove"]] = None, - lab_resource_id: Optional[str] = None, **kwargs ): - super(PersonalPreferencesOperationsPayload, self).__init__(**kwargs) - self.lab_account_resource_id = lab_account_resource_id - self.add_remove = add_remove - self.lab_resource_id = lab_resource_id + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationResult(msrest.serialization.Model): + """A long running operation result. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar status: Required. The operation status. Possible values include: "NotStarted", + "InProgress", "Succeeded", "Failed", "Canceled". + :vartype status: str or ~azure.mgmt.labservices.models.OperationStatus + :ivar start_time: Start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: Percent completion. + :vartype percent_complete: float + :ivar error: The error for a failure if the operation failed. + :vartype error: ~azure.mgmt.labservices.models.ErrorDetail + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'status': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'percent_complete': {'key': 'percentComplete', 'type': 'float'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + status: Union[str, "OperationStatus"], + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + percent_complete: Optional[float] = None, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + """ + :keyword status: Required. The operation status. Possible values include: "NotStarted", + "InProgress", "Succeeded", "Failed", "Canceled". + :paramtype status: str or ~azure.mgmt.labservices.models.OperationStatus + :keyword start_time: Start time. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time. + :paramtype end_time: ~datetime.datetime + :keyword percent_complete: Percent completion. + :paramtype percent_complete: float + :keyword error: The error for a failure if the operation failed. + :paramtype error: ~azure.mgmt.labservices.models.ErrorDetail + """ + super(OperationResult, self).__init__(**kwargs) + self.id = None + self.name = None + self.status = status + self.start_time = start_time + self.end_time = end_time + self.percent_complete = percent_complete + self.error = error -class ProviderOperationResult(msrest.serialization.Model): - """Result of the request to list REST API operations. +class PagedImages(msrest.serialization.Model): + """Paged list of Lab services virtual machine images. 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.labservices.models.OperationMetadata] - :ivar next_link: URL to get the next set of operation list results if there are any. + :ivar value: The array page of virtual machine images. + :vartype value: list[~azure.mgmt.labservices.models.Image] + :ivar next_link: The link to get the next page of image results. :vartype next_link: str """ _validation = { + 'value': {'readonly': True}, 'next_link': {'readonly': True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationMetadata]'}, + 'value': {'key': 'value', 'type': '[Image]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - value: Optional[List["OperationMetadata"]] = None, **kwargs ): - super(ProviderOperationResult, self).__init__(**kwargs) - self.value = value + """ + """ + super(PagedImages, self).__init__(**kwargs) + self.value = None self.next_link = None -class PublishPayload(msrest.serialization.Model): - """Payload for Publish operation on EnvironmentSetting. +class PagedLabPlans(msrest.serialization.Model): + """Paged list of lab plans. - :param use_existing_image: Whether to use existing VM custom image when publishing. - :type use_existing_image: bool + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array page of lab plans. + :vartype value: list[~azure.mgmt.labservices.models.LabPlan] + :ivar next_link: The link to get the next page of lab plan results. + :vartype next_link: str """ + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'use_existing_image': {'key': 'useExistingImage', 'type': 'bool'}, + 'value': {'key': 'value', 'type': '[LabPlan]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - use_existing_image: Optional[bool] = None, **kwargs ): - super(PublishPayload, self).__init__(**kwargs) - self.use_existing_image = use_existing_image + """ + """ + super(PagedLabPlans, self).__init__(**kwargs) + self.value = None + self.next_link = None -class ReferenceVm(msrest.serialization.Model): - """Details of a Reference Vm. +class PagedLabs(msrest.serialization.Model): + """Paged list of labs. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :param user_name: Required. The username of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine. This will be set to null in GET resource - API. - :type password: str - :ivar vm_state_details: The state details for the reference virtual machine. - :vartype vm_state_details: ~azure.mgmt.labservices.models.VmStateDetails - :ivar vm_resource_id: VM resource Id for the environment. - :vartype vm_resource_id: str + :ivar value: The array page of lab results. + :vartype value: list[~azure.mgmt.labservices.models.Lab] + :ivar next_link: The link to get the next page of image results. + :vartype next_link: str """ _validation = { - 'user_name': {'required': True}, - 'vm_state_details': {'readonly': True}, - 'vm_resource_id': {'readonly': True}, + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, } _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'vm_state_details': {'key': 'vmStateDetails', 'type': 'VmStateDetails'}, - 'vm_resource_id': {'key': 'vmResourceId', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Lab]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - user_name: str, - password: Optional[str] = None, **kwargs ): - super(ReferenceVm, self).__init__(**kwargs) - self.user_name = user_name - self.password = password - self.vm_state_details = None - self.vm_resource_id = None + """ + """ + super(PagedLabs, self).__init__(**kwargs) + self.value = None + self.next_link = None -class ReferenceVmCreationParameters(msrest.serialization.Model): - """Creation parameters for Reference Vm. +class PagedLabServicesSkus(msrest.serialization.Model): + """Paged list of lab services skus. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param user_name: Required. The username of the virtual machine. - :type user_name: str - :param password: Required. The password of the virtual machine. - :type password: str + :ivar value: The array page of sku results. + :vartype value: list[~azure.mgmt.labservices.models.LabServicesSku] + :ivar next_link: The link to get the next page of sku results. + :vartype next_link: str """ _validation = { - 'user_name': {'required': True}, - 'password': {'required': True}, + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, } _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[LabServicesSku]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - user_name: str, - password: str, **kwargs ): - super(ReferenceVmCreationParameters, self).__init__(**kwargs) - self.user_name = user_name - self.password = password + """ + """ + super(PagedLabServicesSkus, self).__init__(**kwargs) + self.value = None + self.next_link = None -class ReferenceVmFragment(msrest.serialization.Model): - """Details of a Reference Vm. +class PagedSchedules(msrest.serialization.Model): + """Paged list of schedules. - :param user_name: The username of the virtual machine. - :type user_name: str - :param password: The password of the virtual machine. This will be set to null in GET resource - API. - :type password: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array page of schedule results. + :vartype value: list[~azure.mgmt.labservices.models.Schedule] + :ivar next_link: The link to get the next page of schedule results. + :vartype next_link: str """ + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Schedule]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - user_name: Optional[str] = None, - password: Optional[str] = None, **kwargs ): - super(ReferenceVmFragment, self).__init__(**kwargs) - self.user_name = user_name - self.password = password + """ + """ + super(PagedSchedules, self).__init__(**kwargs) + self.value = None + self.next_link = None + +class PagedUsers(msrest.serialization.Model): + """Paged list of users. -class RegionalAvailability(msrest.serialization.Model): - """The availability information of sizes across regions. + Variables are only populated by the server, and will be ignored when sending a request. - :param region: Corresponding region. - :type region: str - :param size_availabilities: List of all the size information for the region. - :type size_availabilities: list[~azure.mgmt.labservices.models.SizeAvailability] + :ivar value: The array page of user results. + :vartype value: list[~azure.mgmt.labservices.models.User] + :ivar next_link: The link to get the next page of image results. + :vartype next_link: str """ + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'region': {'key': 'region', 'type': 'str'}, - 'size_availabilities': {'key': 'sizeAvailabilities', 'type': '[SizeAvailability]'}, + 'value': {'key': 'value', 'type': '[User]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - region: Optional[str] = None, - size_availabilities: Optional[List["SizeAvailability"]] = None, **kwargs ): - super(RegionalAvailability, self).__init__(**kwargs) - self.region = region - self.size_availabilities = size_availabilities + """ + """ + super(PagedUsers, self).__init__(**kwargs) + self.value = None + self.next_link = None -class RegisterPayload(msrest.serialization.Model): - """Represents payload for Register action. +class PagedVirtualMachines(msrest.serialization.Model): + """Paged list of lab services virtual machines. - :param registration_code: The registration code of the lab. - :type registration_code: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array page of virtual machine results. + :vartype value: list[~azure.mgmt.labservices.models.VirtualMachine] + :ivar next_link: The link to get the next page of virtual machine results. + :vartype next_link: str """ + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'registration_code': {'key': 'registrationCode', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[VirtualMachine]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - registration_code: Optional[str] = None, **kwargs ): - super(RegisterPayload, self).__init__(**kwargs) - self.registration_code = registration_code + """ + """ + super(PagedVirtualMachines, self).__init__(**kwargs) + self.value = None + self.next_link = None -class ResetPasswordPayload(msrest.serialization.Model): - """Represents the payload for resetting passwords. +class RecurrencePattern(msrest.serialization.Model): + """Recurrence pattern of a lab schedule. All required parameters must be populated in order to send to Azure. - :param environment_id: Required. The resourceId of the environment. - :type environment_id: str - :param username: The username for which the password will be reset. - :type username: str - :param password: The password to assign to the user specified in. - :type password: str + :ivar frequency: Required. The frequency of the recurrence. Possible values include: "Daily", + "Weekly". + :vartype frequency: str or ~azure.mgmt.labservices.models.RecurrenceFrequency + :ivar week_days: The week days the schedule runs. Used for when the Frequency is set to Weekly. + :vartype week_days: list[str or ~azure.mgmt.labservices.models.WeekDay] + :ivar interval: The interval to invoke the schedule on. For example, interval = 2 and + RecurrenceFrequency.Daily will run every 2 days. When no interval is supplied, an interval of 1 + is used. + :vartype interval: int + :ivar expiration_date: Required. When the recurrence will expire. This date is inclusive. + :vartype expiration_date: ~datetime.date """ _validation = { - 'environment_id': {'required': True}, + 'frequency': {'required': True}, + 'interval': {'maximum': 365, 'minimum': 1}, + 'expiration_date': {'required': True}, } _attribute_map = { - 'environment_id': {'key': 'environmentId', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + 'frequency': {'key': 'frequency', 'type': 'str'}, + 'week_days': {'key': 'weekDays', 'type': '[str]'}, + 'interval': {'key': 'interval', 'type': 'int'}, + 'expiration_date': {'key': 'expirationDate', 'type': 'date'}, } def __init__( self, *, - environment_id: str, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): - super(ResetPasswordPayload, self).__init__(**kwargs) - self.environment_id = environment_id - self.username = username - self.password = password + frequency: Union[str, "RecurrenceFrequency"], + expiration_date: datetime.date, + week_days: Optional[List[Union[str, "WeekDay"]]] = None, + interval: Optional[int] = None, + **kwargs + ): + """ + :keyword frequency: Required. The frequency of the recurrence. Possible values include: + "Daily", "Weekly". + :paramtype frequency: str or ~azure.mgmt.labservices.models.RecurrenceFrequency + :keyword week_days: The week days the schedule runs. Used for when the Frequency is set to + Weekly. + :paramtype week_days: list[str or ~azure.mgmt.labservices.models.WeekDay] + :keyword interval: The interval to invoke the schedule on. For example, interval = 2 and + RecurrenceFrequency.Daily will run every 2 days. When no interval is supplied, an interval of 1 + is used. + :paramtype interval: int + :keyword expiration_date: Required. When the recurrence will expire. This date is inclusive. + :paramtype expiration_date: ~datetime.date + """ + super(RecurrencePattern, self).__init__(**kwargs) + self.frequency = frequency + self.week_days = week_days + self.interval = interval + self.expiration_date = expiration_date + + +class ResetPasswordBody(msrest.serialization.Model): + """Body of a reset password request. + All required parameters must be populated in order to send to Azure. -class ResourceSet(msrest.serialization.Model): - """Represents a VM and the setting Id it was created for. - - :param vm_resource_id: VM resource Id for the environment. - :type vm_resource_id: str - :param resource_setting_id: resourceSettingId for the environment. - :type resource_setting_id: str + :ivar username: Required. The user whose password is being reset. + :vartype username: str + :ivar password: Required. The password. + :vartype password: str """ + _validation = { + 'username': {'required': True}, + 'password': {'required': True}, + } + _attribute_map = { - 'vm_resource_id': {'key': 'vmResourceId', 'type': 'str'}, - 'resource_setting_id': {'key': 'resourceSettingId', 'type': 'str'}, + 'username': {'key': 'username', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, } def __init__( self, *, - vm_resource_id: Optional[str] = None, - resource_setting_id: Optional[str] = None, + username: str, + password: str, **kwargs ): - super(ResourceSet, self).__init__(**kwargs) - self.vm_resource_id = vm_resource_id - self.resource_setting_id = resource_setting_id + """ + :keyword username: Required. The user whose password is being reset. + :paramtype username: str + :keyword password: Required. The password. + :paramtype password: str + """ + super(ResetPasswordBody, self).__init__(**kwargs) + self.username = username + self.password = password -class ResourceSetFragment(msrest.serialization.Model): - """Represents a VM and the setting Id it was created for. +class RosterProfile(msrest.serialization.Model): + """The lab user list management profile. - :param vm_resource_id: VM resource Id for the environment. - :type vm_resource_id: str - :param resource_setting_id: resourceSettingId for the environment. - :type resource_setting_id: str + :ivar active_directory_group_id: The AAD group ID which this lab roster is populated from. + Having this set enables AAD sync mode. + :vartype active_directory_group_id: str + :ivar lti_context_id: The unique context identifier for the lab in the lms. + :vartype lti_context_id: str + :ivar lms_instance: The base URI identifying the lms instance. + :vartype lms_instance: str + :ivar lti_client_id: The unique id of the azure lab services tool in the lms. + :vartype lti_client_id: str + :ivar lti_roster_endpoint: The uri of the names and roles service endpoint on the lms for the + class attached to this lab. + :vartype lti_roster_endpoint: str """ _attribute_map = { - 'vm_resource_id': {'key': 'vmResourceId', 'type': 'str'}, - 'resource_setting_id': {'key': 'resourceSettingId', 'type': 'str'}, + 'active_directory_group_id': {'key': 'activeDirectoryGroupId', 'type': 'str'}, + 'lti_context_id': {'key': 'ltiContextId', 'type': 'str'}, + 'lms_instance': {'key': 'lmsInstance', 'type': 'str'}, + 'lti_client_id': {'key': 'ltiClientId', 'type': 'str'}, + 'lti_roster_endpoint': {'key': 'ltiRosterEndpoint', 'type': 'str'}, } def __init__( self, *, - vm_resource_id: Optional[str] = None, - resource_setting_id: Optional[str] = None, - **kwargs - ): - super(ResourceSetFragment, self).__init__(**kwargs) - self.vm_resource_id = vm_resource_id - self.resource_setting_id = resource_setting_id - - -class ResourceSettingCreationParameters(msrest.serialization.Model): - """Represents resource specific settings. - - All required parameters must be populated in order to send to Azure. - - :param location: The location where the virtual machine will live. - :type location: str - :param name: The name of the resource setting. - :type name: str - :param gallery_image_resource_id: Required. The resource id of the gallery image used for - creating the virtual machine. - :type gallery_image_resource_id: str - :param size: The size of the virtual machine. Possible values include: "Basic", "Standard", - "Performance". - :type size: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param reference_vm_creation_parameters: Required. Creation parameters for Reference Vm. - :type reference_vm_creation_parameters: - ~azure.mgmt.labservices.models.ReferenceVmCreationParameters + active_directory_group_id: Optional[str] = None, + lti_context_id: Optional[str] = None, + lms_instance: Optional[str] = None, + lti_client_id: Optional[str] = None, + lti_roster_endpoint: Optional[str] = None, + **kwargs + ): + """ + :keyword active_directory_group_id: The AAD group ID which this lab roster is populated from. + Having this set enables AAD sync mode. + :paramtype active_directory_group_id: str + :keyword lti_context_id: The unique context identifier for the lab in the lms. + :paramtype lti_context_id: str + :keyword lms_instance: The base URI identifying the lms instance. + :paramtype lms_instance: str + :keyword lti_client_id: The unique id of the azure lab services tool in the lms. + :paramtype lti_client_id: str + :keyword lti_roster_endpoint: The uri of the names and roles service endpoint on the lms for + the class attached to this lab. + :paramtype lti_roster_endpoint: str + """ + super(RosterProfile, self).__init__(**kwargs) + self.active_directory_group_id = active_directory_group_id + self.lti_context_id = lti_context_id + self.lms_instance = lms_instance + self.lti_client_id = lti_client_id + self.lti_roster_endpoint = lti_roster_endpoint + + +class SaveImageBody(msrest.serialization.Model): + """Body for the save image POST. + + :ivar name: The name for the image we create. + :vartype name: str + :ivar lab_virtual_machine_id: The ID of the lab virtual machine you want to save an image from. + :vartype lab_virtual_machine_id: str """ _validation = { - 'gallery_image_resource_id': {'required': True}, - 'reference_vm_creation_parameters': {'required': True}, + 'lab_virtual_machine_id': {'max_length': 2000, 'min_length': 3}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'gallery_image_resource_id': {'key': 'galleryImageResourceId', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'reference_vm_creation_parameters': {'key': 'referenceVmCreationParameters', 'type': 'ReferenceVmCreationParameters'}, + 'lab_virtual_machine_id': {'key': 'labVirtualMachineId', 'type': 'str'}, } def __init__( self, *, - gallery_image_resource_id: str, - reference_vm_creation_parameters: "ReferenceVmCreationParameters", - location: Optional[str] = None, name: Optional[str] = None, - size: Optional[Union[str, "ManagedLabVmSize"]] = None, + lab_virtual_machine_id: Optional[str] = None, **kwargs ): - super(ResourceSettingCreationParameters, self).__init__(**kwargs) - self.location = location + """ + :keyword name: The name for the image we create. + :paramtype name: str + :keyword lab_virtual_machine_id: The ID of the lab virtual machine you want to save an image + from. + :paramtype lab_virtual_machine_id: str + """ + super(SaveImageBody, self).__init__(**kwargs) self.name = name - self.gallery_image_resource_id = gallery_image_resource_id - self.size = size - self.reference_vm_creation_parameters = reference_vm_creation_parameters + self.lab_virtual_machine_id = lab_virtual_machine_id -class ResourceSettings(msrest.serialization.Model): - """Represents resource specific settings. +class Schedule(ProxyResource): + """Schedule for automatically turning virtual machines in a lab on and off at specified times. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar id: The unique id of the resource setting. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :param gallery_image_resource_id: The resource id of the gallery image used for creating the - virtual machine. - :type gallery_image_resource_id: str - :ivar image_name: The name of the image used to created the environment setting. - :vartype image_name: str - :param size: The size of the virtual machine. Possible values include: "Basic", "Standard", - "Performance". - :type size: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :ivar cores: The translated compute cores of the virtual machine. - :vartype cores: int - :param reference_vm: Required. Details specific to Reference Vm. - :type reference_vm: ~azure.mgmt.labservices.models.ReferenceVm + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the schedule. + :vartype system_data: ~azure.mgmt.labservices.models.SystemData + :ivar start_at: When lab user virtual machines will be started. Timestamp offsets will be + ignored and timeZoneId is used instead. + :vartype start_at: ~datetime.datetime + :ivar stop_at: When lab user virtual machines will be stopped. Timestamp offsets will be + ignored and timeZoneId is used instead. + :vartype stop_at: ~datetime.datetime + :ivar recurrence_pattern: The recurrence pattern of the scheduled actions. + :vartype recurrence_pattern: ~azure.mgmt.labservices.models.RecurrencePattern + :ivar time_zone_id: The IANA timezone id for the schedule. + :vartype time_zone_id: str + :ivar notes: Notes for this schedule. + :vartype notes: str + :ivar provisioning_state: Current provisioning state of the schedule. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState """ _validation = { 'id': {'readonly': True}, - 'image_name': {'readonly': True}, - 'cores': {'readonly': True}, - 'reference_vm': {'required': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'time_zone_id': {'max_length': 50, 'min_length': 0}, + 'notes': {'max_length': 1000, 'min_length': 0}, + 'provisioning_state': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, - 'gallery_image_resource_id': {'key': 'galleryImageResourceId', 'type': 'str'}, - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'cores': {'key': 'cores', 'type': 'int'}, - 'reference_vm': {'key': 'referenceVm', 'type': 'ReferenceVm'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'start_at': {'key': 'properties.startAt', 'type': 'iso-8601'}, + 'stop_at': {'key': 'properties.stopAt', 'type': 'iso-8601'}, + 'recurrence_pattern': {'key': 'properties.recurrencePattern', 'type': 'RecurrencePattern'}, + 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } def __init__( self, *, - reference_vm: "ReferenceVm", - gallery_image_resource_id: Optional[str] = None, - size: Optional[Union[str, "ManagedLabVmSize"]] = None, - **kwargs - ): - super(ResourceSettings, self).__init__(**kwargs) - self.id = None - self.gallery_image_resource_id = gallery_image_resource_id - self.image_name = None - self.size = size - self.cores = None - self.reference_vm = reference_vm + start_at: Optional[datetime.datetime] = None, + stop_at: Optional[datetime.datetime] = None, + recurrence_pattern: Optional["RecurrencePattern"] = None, + time_zone_id: Optional[str] = None, + notes: Optional[str] = None, + **kwargs + ): + """ + :keyword start_at: When lab user virtual machines will be started. Timestamp offsets will be + ignored and timeZoneId is used instead. + :paramtype start_at: ~datetime.datetime + :keyword stop_at: When lab user virtual machines will be stopped. Timestamp offsets will be + ignored and timeZoneId is used instead. + :paramtype stop_at: ~datetime.datetime + :keyword recurrence_pattern: The recurrence pattern of the scheduled actions. + :paramtype recurrence_pattern: ~azure.mgmt.labservices.models.RecurrencePattern + :keyword time_zone_id: The IANA timezone id for the schedule. + :paramtype time_zone_id: str + :keyword notes: Notes for this schedule. + :paramtype notes: str + """ + super(Schedule, self).__init__(**kwargs) + self.system_data = None + self.start_at = start_at + self.stop_at = stop_at + self.recurrence_pattern = recurrence_pattern + self.time_zone_id = time_zone_id + self.notes = notes + self.provisioning_state = None -class ResourceSettingsFragment(msrest.serialization.Model): - """Represents resource specific settings. +class ScheduleUpdateProperties(msrest.serialization.Model): + """Schedule resource properties used for updates. - :param gallery_image_resource_id: The resource id of the gallery image used for creating the - virtual machine. - :type gallery_image_resource_id: str - :param size: The size of the virtual machine. Possible values include: "Basic", "Standard", - "Performance". - :type size: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param reference_vm: Details specific to Reference Vm. - :type reference_vm: ~azure.mgmt.labservices.models.ReferenceVmFragment + :ivar start_at: When lab user virtual machines will be started. Timestamp offsets will be + ignored and timeZoneId is used instead. + :vartype start_at: ~datetime.datetime + :ivar stop_at: When lab user virtual machines will be stopped. Timestamp offsets will be + ignored and timeZoneId is used instead. + :vartype stop_at: ~datetime.datetime + :ivar recurrence_pattern: The recurrence pattern of the scheduled actions. + :vartype recurrence_pattern: ~azure.mgmt.labservices.models.RecurrencePattern + :ivar time_zone_id: The IANA timezone id for the schedule. + :vartype time_zone_id: str + :ivar notes: Notes for this schedule. + :vartype notes: str """ + _validation = { + 'time_zone_id': {'max_length': 50, 'min_length': 0}, + 'notes': {'max_length': 1000, 'min_length': 0}, + } + _attribute_map = { - 'gallery_image_resource_id': {'key': 'galleryImageResourceId', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'reference_vm': {'key': 'referenceVm', 'type': 'ReferenceVmFragment'}, + 'start_at': {'key': 'startAt', 'type': 'iso-8601'}, + 'stop_at': {'key': 'stopAt', 'type': 'iso-8601'}, + 'recurrence_pattern': {'key': 'recurrencePattern', 'type': 'RecurrencePattern'}, + 'time_zone_id': {'key': 'timeZoneId', 'type': 'str'}, + 'notes': {'key': 'notes', 'type': 'str'}, } def __init__( self, *, - gallery_image_resource_id: Optional[str] = None, - size: Optional[Union[str, "ManagedLabVmSize"]] = None, - reference_vm: Optional["ReferenceVmFragment"] = None, - **kwargs - ): - super(ResourceSettingsFragment, self).__init__(**kwargs) - self.gallery_image_resource_id = gallery_image_resource_id - self.size = size - self.reference_vm = reference_vm + start_at: Optional[datetime.datetime] = None, + stop_at: Optional[datetime.datetime] = None, + recurrence_pattern: Optional["RecurrencePattern"] = None, + time_zone_id: Optional[str] = None, + notes: Optional[str] = None, + **kwargs + ): + """ + :keyword start_at: When lab user virtual machines will be started. Timestamp offsets will be + ignored and timeZoneId is used instead. + :paramtype start_at: ~datetime.datetime + :keyword stop_at: When lab user virtual machines will be stopped. Timestamp offsets will be + ignored and timeZoneId is used instead. + :paramtype stop_at: ~datetime.datetime + :keyword recurrence_pattern: The recurrence pattern of the scheduled actions. + :paramtype recurrence_pattern: ~azure.mgmt.labservices.models.RecurrencePattern + :keyword time_zone_id: The IANA timezone id for the schedule. + :paramtype time_zone_id: str + :keyword notes: Notes for this schedule. + :paramtype notes: str + """ + super(ScheduleUpdateProperties, self).__init__(**kwargs) + self.start_at = start_at + self.stop_at = stop_at + self.recurrence_pattern = recurrence_pattern + self.time_zone_id = time_zone_id + self.notes = notes + + +class ScheduleProperties(ScheduleUpdateProperties): + """Schedule resource properties. + Variables are only populated by the server, and will be ignored when sending a request. -class ResponseWithContinuationEnvironment(msrest.serialization.Model): - """The response of a list operation. - - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.Environment] - :param next_link: Link for next set of results. - :type next_link: str + :ivar start_at: When lab user virtual machines will be started. Timestamp offsets will be + ignored and timeZoneId is used instead. + :vartype start_at: ~datetime.datetime + :ivar stop_at: When lab user virtual machines will be stopped. Timestamp offsets will be + ignored and timeZoneId is used instead. + :vartype stop_at: ~datetime.datetime + :ivar recurrence_pattern: The recurrence pattern of the scheduled actions. + :vartype recurrence_pattern: ~azure.mgmt.labservices.models.RecurrencePattern + :ivar time_zone_id: The IANA timezone id for the schedule. + :vartype time_zone_id: str + :ivar notes: Notes for this schedule. + :vartype notes: str + :ivar provisioning_state: Current provisioning state of the schedule. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState """ + _validation = { + 'time_zone_id': {'max_length': 50, 'min_length': 0}, + 'notes': {'max_length': 1000, 'min_length': 0}, + 'provisioning_state': {'readonly': True}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': '[Environment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'start_at': {'key': 'startAt', 'type': 'iso-8601'}, + 'stop_at': {'key': 'stopAt', 'type': 'iso-8601'}, + 'recurrence_pattern': {'key': 'recurrencePattern', 'type': 'RecurrencePattern'}, + 'time_zone_id': {'key': 'timeZoneId', 'type': 'str'}, + 'notes': {'key': 'notes', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } def __init__( self, *, - value: Optional[List["Environment"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(ResponseWithContinuationEnvironment, self).__init__(**kwargs) - self.value = value - self.next_link = next_link + start_at: Optional[datetime.datetime] = None, + stop_at: Optional[datetime.datetime] = None, + recurrence_pattern: Optional["RecurrencePattern"] = None, + time_zone_id: Optional[str] = None, + notes: Optional[str] = None, + **kwargs + ): + """ + :keyword start_at: When lab user virtual machines will be started. Timestamp offsets will be + ignored and timeZoneId is used instead. + :paramtype start_at: ~datetime.datetime + :keyword stop_at: When lab user virtual machines will be stopped. Timestamp offsets will be + ignored and timeZoneId is used instead. + :paramtype stop_at: ~datetime.datetime + :keyword recurrence_pattern: The recurrence pattern of the scheduled actions. + :paramtype recurrence_pattern: ~azure.mgmt.labservices.models.RecurrencePattern + :keyword time_zone_id: The IANA timezone id for the schedule. + :paramtype time_zone_id: str + :keyword notes: Notes for this schedule. + :paramtype notes: str + """ + super(ScheduleProperties, self).__init__(start_at=start_at, stop_at=stop_at, recurrence_pattern=recurrence_pattern, time_zone_id=time_zone_id, notes=notes, **kwargs) + self.provisioning_state = None -class ResponseWithContinuationEnvironmentSetting(msrest.serialization.Model): - """The response of a list operation. +class ScheduleUpdate(msrest.serialization.Model): + """Schedule for automatically turning virtual machines in a lab on and off at specified times. Used for updates. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.EnvironmentSetting] - :param next_link: Link for next set of results. - :type next_link: str + :ivar start_at: When lab user virtual machines will be started. Timestamp offsets will be + ignored and timeZoneId is used instead. + :vartype start_at: ~datetime.datetime + :ivar stop_at: When lab user virtual machines will be stopped. Timestamp offsets will be + ignored and timeZoneId is used instead. + :vartype stop_at: ~datetime.datetime + :ivar recurrence_pattern: The recurrence pattern of the scheduled actions. + :vartype recurrence_pattern: ~azure.mgmt.labservices.models.RecurrencePattern + :ivar time_zone_id: The IANA timezone id for the schedule. + :vartype time_zone_id: str + :ivar notes: Notes for this schedule. + :vartype notes: str """ + _validation = { + 'time_zone_id': {'max_length': 50, 'min_length': 0}, + 'notes': {'max_length': 1000, 'min_length': 0}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': '[EnvironmentSetting]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'start_at': {'key': 'properties.startAt', 'type': 'iso-8601'}, + 'stop_at': {'key': 'properties.stopAt', 'type': 'iso-8601'}, + 'recurrence_pattern': {'key': 'properties.recurrencePattern', 'type': 'RecurrencePattern'}, + 'time_zone_id': {'key': 'properties.timeZoneId', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, } def __init__( self, *, - value: Optional[List["EnvironmentSetting"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(ResponseWithContinuationEnvironmentSetting, self).__init__(**kwargs) - self.value = value - self.next_link = next_link - + start_at: Optional[datetime.datetime] = None, + stop_at: Optional[datetime.datetime] = None, + recurrence_pattern: Optional["RecurrencePattern"] = None, + time_zone_id: Optional[str] = None, + notes: Optional[str] = None, + **kwargs + ): + """ + :keyword start_at: When lab user virtual machines will be started. Timestamp offsets will be + ignored and timeZoneId is used instead. + :paramtype start_at: ~datetime.datetime + :keyword stop_at: When lab user virtual machines will be stopped. Timestamp offsets will be + ignored and timeZoneId is used instead. + :paramtype stop_at: ~datetime.datetime + :keyword recurrence_pattern: The recurrence pattern of the scheduled actions. + :paramtype recurrence_pattern: ~azure.mgmt.labservices.models.RecurrencePattern + :keyword time_zone_id: The IANA timezone id for the schedule. + :paramtype time_zone_id: str + :keyword notes: Notes for this schedule. + :paramtype notes: str + """ + super(ScheduleUpdate, self).__init__(**kwargs) + self.start_at = start_at + self.stop_at = stop_at + self.recurrence_pattern = recurrence_pattern + self.time_zone_id = time_zone_id + self.notes = notes + + +class SecurityProfile(msrest.serialization.Model): + """The lab security profile. -class ResponseWithContinuationGalleryImage(msrest.serialization.Model): - """The response of a list operation. + Variables are only populated by the server, and will be ignored when sending a request. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.GalleryImage] - :param next_link: Link for next set of results. - :type next_link: str + :ivar registration_code: The registration code for the lab. + :vartype registration_code: str + :ivar open_access: Whether any user or only specified users can register to a lab. Possible + values include: "Enabled", "Disabled". + :vartype open_access: str or ~azure.mgmt.labservices.models.EnableState """ + _validation = { + 'registration_code': {'readonly': True}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': '[GalleryImage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'registration_code': {'key': 'registrationCode', 'type': 'str'}, + 'open_access': {'key': 'openAccess', 'type': 'str'}, } def __init__( self, *, - value: Optional[List["GalleryImage"]] = None, - next_link: Optional[str] = None, + open_access: Optional[Union[str, "EnableState"]] = None, **kwargs ): - super(ResponseWithContinuationGalleryImage, self).__init__(**kwargs) - self.value = value - self.next_link = next_link + """ + :keyword open_access: Whether any user or only specified users can register to a lab. Possible + values include: "Enabled", "Disabled". + :paramtype open_access: str or ~azure.mgmt.labservices.models.EnableState + """ + super(SecurityProfile, self).__init__(**kwargs) + self.registration_code = None + self.open_access = open_access + +class Sku(msrest.serialization.Model): + """The resource model definition representing SKU. -class ResponseWithContinuationLab(msrest.serialization.Model): - """The response of a list operation. + All required parameters must be populated in order to send to Azure. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.Lab] - :param next_link: Link for next set of results. - :type next_link: str + :ivar name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. + :vartype name: str + :ivar tier: This field is required to be implemented by the Resource Provider if the service + has more than one tier, but is not required on a PUT. Possible values include: "Free", "Basic", + "Standard", "Premium". + :vartype tier: str or ~azure.mgmt.labservices.models.SkuTier + :ivar size: The SKU size. When the name field is the combination of tier and some other value, + this would be the standalone code. + :vartype size: str + :ivar family: If the service has different generations of hardware, for the same SKU, then that + can be captured here. + :vartype family: str + :ivar capacity: If the SKU supports scale out/in then the capacity integer should be included. + If scale out/in is not possible for the resource this may be omitted. + :vartype capacity: int """ + _validation = { + 'name': {'required': True}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': '[Lab]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, } def __init__( self, *, - value: Optional[List["Lab"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(ResponseWithContinuationLab, self).__init__(**kwargs) - self.value = value - self.next_link = next_link + name: str, + tier: Optional[Union[str, "SkuTier"]] = None, + size: Optional[str] = None, + family: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. + :paramtype name: str + :keyword tier: This field is required to be implemented by the Resource Provider if the service + has more than one tier, but is not required on a PUT. Possible values include: "Free", "Basic", + "Standard", "Premium". + :paramtype tier: str or ~azure.mgmt.labservices.models.SkuTier + :keyword size: The SKU size. When the name field is the combination of tier and some other + value, this would be the standalone code. + :paramtype size: str + :keyword family: If the service has different generations of hardware, for the same SKU, then + that can be captured here. + :paramtype family: str + :keyword capacity: If the SKU supports scale out/in then the capacity integer should be + included. If scale out/in is not possible for the resource this may be omitted. + :paramtype capacity: int + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.capacity = capacity -class ResponseWithContinuationLabAccount(msrest.serialization.Model): - """The response of a list operation. +class SupportInfo(msrest.serialization.Model): + """Support contact information and instructions. - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.LabAccount] - :param next_link: Link for next set of results. - :type next_link: str + :ivar url: Support web address. + :vartype url: str + :ivar email: Support contact email address. + :vartype email: str + :ivar phone: Support contact phone number. + :vartype phone: str + :ivar instructions: Support instructions. + :vartype instructions: str """ + _validation = { + 'url': {'max_length': 2000, 'min_length': 3}, + 'email': {'max_length': 254, 'min_length': 6}, + 'phone': {'max_length': 31, 'min_length': 1}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': '[LabAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'phone': {'key': 'phone', 'type': 'str'}, + 'instructions': {'key': 'instructions', 'type': 'str'}, } def __init__( self, *, - value: Optional[List["LabAccount"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(ResponseWithContinuationLabAccount, self).__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResponseWithContinuationUser(msrest.serialization.Model): - """The response of a list operation. + url: Optional[str] = None, + email: Optional[str] = None, + phone: Optional[str] = None, + instructions: Optional[str] = None, + **kwargs + ): + """ + :keyword url: Support web address. + :paramtype url: str + :keyword email: Support contact email address. + :paramtype email: str + :keyword phone: Support contact phone number. + :paramtype phone: str + :keyword instructions: Support instructions. + :paramtype instructions: str + """ + super(SupportInfo, self).__init__(**kwargs) + self.url = url + self.email = email + self.phone = phone + self.instructions = instructions + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.labservices.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.labservices.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } - :param value: Results of the list operation. - :type value: list[~azure.mgmt.labservices.models.User] - :param next_link: Link for next set of results. - :type next_link: str + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.labservices.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.labservices.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class Usage(msrest.serialization.Model): + """The core usage details. + + :ivar current_value: The current usage. + :vartype current_value: long + :ivar limit: The limit integer. + :vartype limit: long + :ivar unit: The unit details. Possible values include: "Count". + :vartype unit: str or ~azure.mgmt.labservices.models.UsageUnit + :ivar name: The name. + :vartype name: ~azure.mgmt.labservices.models.UsageName + :ivar id: The fully qualified arm resource id. + :vartype id: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_value': {'key': 'currentValue', 'type': 'long'}, + 'limit': {'key': 'limit', 'type': 'long'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'UsageName'}, + 'id': {'key': 'id', 'type': 'str'}, } def __init__( self, *, - value: Optional[List["User"]] = None, - next_link: Optional[str] = None, + current_value: Optional[int] = None, + limit: Optional[int] = None, + unit: Optional[Union[str, "UsageUnit"]] = None, + name: Optional["UsageName"] = None, + id: Optional[str] = None, **kwargs ): - super(ResponseWithContinuationUser, self).__init__(**kwargs) - self.value = value - self.next_link = next_link + """ + :keyword current_value: The current usage. + :paramtype current_value: long + :keyword limit: The limit integer. + :paramtype limit: long + :keyword unit: The unit details. Possible values include: "Count". + :paramtype unit: str or ~azure.mgmt.labservices.models.UsageUnit + :keyword name: The name. + :paramtype name: ~azure.mgmt.labservices.models.UsageName + :keyword id: The fully qualified arm resource id. + :paramtype id: str + """ + super(Usage, self).__init__(**kwargs) + self.current_value = current_value + self.limit = limit + self.unit = unit + self.name = name + self.id = id -class SizeAvailability(msrest.serialization.Model): - """Represents the size information. +class UsageName(msrest.serialization.Model): + """The Usage Names. - :param size_category: The category of the size (Basic, Standard, Performance). Possible values - include: "Basic", "Standard", "Performance". - :type size_category: str or ~azure.mgmt.labservices.models.ManagedLabVmSize - :param is_available: Whether or not this size category is available. - :type is_available: bool + :ivar localized_value: The localized name of the resource. + :vartype localized_value: str + :ivar value: The name of the resource. + :vartype value: str """ _attribute_map = { - 'size_category': {'key': 'sizeCategory', 'type': 'str'}, - 'is_available': {'key': 'isAvailable', 'type': 'bool'}, + 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, } def __init__( self, *, - size_category: Optional[Union[str, "ManagedLabVmSize"]] = None, - is_available: Optional[bool] = None, - **kwargs - ): - super(SizeAvailability, self).__init__(**kwargs) - self.size_category = size_category - self.is_available = is_available + localized_value: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): + """ + :keyword localized_value: The localized name of the resource. + :paramtype localized_value: str + :keyword value: The name of the resource. + :paramtype value: str + """ + super(UsageName, self).__init__(**kwargs) + self.localized_value = localized_value + self.value = value + +class User(ProxyResource): + """User of a lab that can register for and use virtual machines within the lab. -class SizeConfigurationProperties(msrest.serialization.Model): - """Represents the size configuration under the lab account. + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. - :param environment_sizes: Represents a list of size categories supported by this Lab Account - (Small, Medium, Large). - :type environment_sizes: list[~azure.mgmt.labservices.models.EnvironmentSize] + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the user resource. + :vartype system_data: ~azure.mgmt.labservices.models.SystemData + :ivar additional_usage_quota: The amount of usage quota time the user gets in addition to the + lab usage quota. + :vartype additional_usage_quota: ~datetime.timedelta + :ivar provisioning_state: Current provisioning state of the user resource. Possible values + include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState + :ivar display_name: Display name of the user, for example user's full name. + :vartype display_name: str + :ivar email: Required. Email address of the user. + :vartype email: str + :ivar registration_state: State of the user's registration within the lab. Possible values + include: "Registered", "NotRegistered". + :vartype registration_state: str or ~azure.mgmt.labservices.models.RegistrationState + :ivar invitation_state: State of the invitation message for the user. Possible values include: + "NotSent", "Sending", "Sent", "Failed". + :vartype invitation_state: str or ~azure.mgmt.labservices.models.InvitationState + :ivar invitation_sent: Date and time when the invitation message was sent to the user. + :vartype invitation_sent: ~datetime.datetime + :ivar total_usage: How long the user has used their virtual machines in this lab. + :vartype total_usage: ~datetime.timedelta """ + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'display_name': {'readonly': True}, + 'email': {'required': True, 'max_length': 254, 'min_length': 6}, + 'registration_state': {'readonly': True}, + 'invitation_state': {'readonly': True}, + 'invitation_sent': {'readonly': True}, + 'total_usage': {'readonly': True}, + } + _attribute_map = { - 'environment_sizes': {'key': 'environmentSizes', 'type': '[EnvironmentSize]'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'additional_usage_quota': {'key': 'properties.additionalUsageQuota', 'type': 'duration'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'email': {'key': 'properties.email', 'type': 'str'}, + 'registration_state': {'key': 'properties.registrationState', 'type': 'str'}, + 'invitation_state': {'key': 'properties.invitationState', 'type': 'str'}, + 'invitation_sent': {'key': 'properties.invitationSent', 'type': 'iso-8601'}, + 'total_usage': {'key': 'properties.totalUsage', 'type': 'duration'}, } def __init__( self, *, - environment_sizes: Optional[List["EnvironmentSize"]] = None, - **kwargs - ): - super(SizeConfigurationProperties, self).__init__(**kwargs) - self.environment_sizes = environment_sizes + email: str, + additional_usage_quota: Optional[datetime.timedelta] = None, + **kwargs + ): + """ + :keyword additional_usage_quota: The amount of usage quota time the user gets in addition to + the lab usage quota. + :paramtype additional_usage_quota: ~datetime.timedelta + :keyword email: Required. Email address of the user. + :paramtype email: str + """ + super(User, self).__init__(**kwargs) + self.system_data = None + self.additional_usage_quota = additional_usage_quota + self.provisioning_state = None + self.display_name = None + self.email = email + self.registration_state = None + self.invitation_state = None + self.invitation_sent = None + self.total_usage = None -class SizeConfigurationPropertiesFragment(msrest.serialization.Model): - """Represents the size configuration under the lab account. +class UserUpdateProperties(msrest.serialization.Model): + """User resource properties used for updates. - :param environment_sizes: Represents a list of size categories supported by this Lab Account - (Small, Medium, Large). - :type environment_sizes: list[~azure.mgmt.labservices.models.EnvironmentSizeFragment] + :ivar additional_usage_quota: The amount of usage quota time the user gets in addition to the + lab usage quota. + :vartype additional_usage_quota: ~datetime.timedelta """ _attribute_map = { - 'environment_sizes': {'key': 'environmentSizes', 'type': '[EnvironmentSizeFragment]'}, + 'additional_usage_quota': {'key': 'additionalUsageQuota', 'type': 'duration'}, } def __init__( self, *, - environment_sizes: Optional[List["EnvironmentSizeFragment"]] = None, + additional_usage_quota: Optional[datetime.timedelta] = None, **kwargs ): - super(SizeConfigurationPropertiesFragment, self).__init__(**kwargs) - self.environment_sizes = environment_sizes + """ + :keyword additional_usage_quota: The amount of usage quota time the user gets in addition to + the lab usage quota. + :paramtype additional_usage_quota: ~datetime.timedelta + """ + super(UserUpdateProperties, self).__init__(**kwargs) + self.additional_usage_quota = additional_usage_quota + +class UserProperties(UserUpdateProperties): + """User resource properties. -class SizeInfo(msrest.serialization.Model): - """Contains detailed information about a size. + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. - :param compute_size: Represents the actual compute size, e.g. Standard_A2_v2. - :type compute_size: str - :param price: The pay-as-you-go price per hour this size will cost. It does not include - discounts and may not reflect the actual price the size will cost. - :type price: float - :param number_of_cores: The number of cores a VM of this size has. - :type number_of_cores: int - :param memory: The amount of memory available (in GB). - :type memory: float + :ivar additional_usage_quota: The amount of usage quota time the user gets in addition to the + lab usage quota. + :vartype additional_usage_quota: ~datetime.timedelta + :ivar provisioning_state: Current provisioning state of the user resource. Possible values + include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState + :ivar display_name: Display name of the user, for example user's full name. + :vartype display_name: str + :ivar email: Required. Email address of the user. + :vartype email: str + :ivar registration_state: State of the user's registration within the lab. Possible values + include: "Registered", "NotRegistered". + :vartype registration_state: str or ~azure.mgmt.labservices.models.RegistrationState + :ivar invitation_state: State of the invitation message for the user. Possible values include: + "NotSent", "Sending", "Sent", "Failed". + :vartype invitation_state: str or ~azure.mgmt.labservices.models.InvitationState + :ivar invitation_sent: Date and time when the invitation message was sent to the user. + :vartype invitation_sent: ~datetime.datetime + :ivar total_usage: How long the user has used their virtual machines in this lab. + :vartype total_usage: ~datetime.timedelta """ + _validation = { + 'provisioning_state': {'readonly': True}, + 'display_name': {'readonly': True}, + 'email': {'required': True, 'max_length': 254, 'min_length': 6}, + 'registration_state': {'readonly': True}, + 'invitation_state': {'readonly': True}, + 'invitation_sent': {'readonly': True}, + 'total_usage': {'readonly': True}, + } + _attribute_map = { - 'compute_size': {'key': 'computeSize', 'type': 'str'}, - 'price': {'key': 'price', 'type': 'float'}, - 'number_of_cores': {'key': 'numberOfCores', 'type': 'int'}, - 'memory': {'key': 'memory', 'type': 'float'}, + 'additional_usage_quota': {'key': 'additionalUsageQuota', 'type': 'duration'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'registration_state': {'key': 'registrationState', 'type': 'str'}, + 'invitation_state': {'key': 'invitationState', 'type': 'str'}, + 'invitation_sent': {'key': 'invitationSent', 'type': 'iso-8601'}, + 'total_usage': {'key': 'totalUsage', 'type': 'duration'}, } def __init__( self, *, - compute_size: Optional[str] = None, - price: Optional[float] = None, - number_of_cores: Optional[int] = None, - memory: Optional[float] = None, - **kwargs - ): - super(SizeInfo, self).__init__(**kwargs) - self.compute_size = compute_size - self.price = price - self.number_of_cores = number_of_cores - self.memory = memory + email: str, + additional_usage_quota: Optional[datetime.timedelta] = None, + **kwargs + ): + """ + :keyword additional_usage_quota: The amount of usage quota time the user gets in addition to + the lab usage quota. + :paramtype additional_usage_quota: ~datetime.timedelta + :keyword email: Required. Email address of the user. + :paramtype email: str + """ + super(UserProperties, self).__init__(additional_usage_quota=additional_usage_quota, **kwargs) + self.provisioning_state = None + self.display_name = None + self.email = email + self.registration_state = None + self.invitation_state = None + self.invitation_sent = None + self.total_usage = None -class SizeInfoFragment(msrest.serialization.Model): - """Contains detailed information about a size. +class UserUpdate(msrest.serialization.Model): + """User of a lab that can register for and use virtual machines within the lab. Used for updates. - :param compute_size: Represents the actual compute size, e.g. Standard_A2_v2. - :type compute_size: str - :param price: The pay-as-you-go price per hour this size will cost. It does not include - discounts and may not reflect the actual price the size will cost. - :type price: float - :param number_of_cores: The number of cores a VM of this size has. - :type number_of_cores: int - :param memory: The amount of memory available (in GB). - :type memory: float + :ivar additional_usage_quota: The amount of usage quota time the user gets in addition to the + lab usage quota. + :vartype additional_usage_quota: ~datetime.timedelta """ _attribute_map = { - 'compute_size': {'key': 'computeSize', 'type': 'str'}, - 'price': {'key': 'price', 'type': 'float'}, - 'number_of_cores': {'key': 'numberOfCores', 'type': 'int'}, - 'memory': {'key': 'memory', 'type': 'float'}, + 'additional_usage_quota': {'key': 'properties.additionalUsageQuota', 'type': 'duration'}, } def __init__( self, *, - compute_size: Optional[str] = None, - price: Optional[float] = None, - number_of_cores: Optional[int] = None, - memory: Optional[float] = None, + additional_usage_quota: Optional[datetime.timedelta] = None, **kwargs ): - super(SizeInfoFragment, self).__init__(**kwargs) - self.compute_size = compute_size - self.price = price - self.number_of_cores = number_of_cores - self.memory = memory + """ + :keyword additional_usage_quota: The amount of usage quota time the user gets in addition to + the lab usage quota. + :paramtype additional_usage_quota: ~datetime.timedelta + """ + super(UserUpdate, self).__init__(**kwargs) + self.additional_usage_quota = additional_usage_quota -class User(Resource): - """The User registered to a lab. +class VirtualMachine(ProxyResource): + """A lab virtual machine resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The identifier of the resource. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :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 email: The user email address, as it was specified during registration. - :vartype email: str - :ivar family_name: The user family name, as it was specified during registration. - :vartype family_name: str - :ivar given_name: The user given name, as it was specified during registration. - :vartype given_name: str - :ivar tenant_id: The user tenant ID, as it was specified during registration. - :vartype tenant_id: str - :ivar total_usage: How long the user has used his VMs in this lab. - :vartype total_usage: ~datetime.timedelta - :param provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str - :ivar latest_operation_result: The details of the latest operation. ex: status, error. - :vartype latest_operation_result: ~azure.mgmt.labservices.models.LatestOperationResult + :ivar system_data: System data of the Lab virtual machine. + :vartype system_data: ~azure.mgmt.labservices.models.SystemData + :ivar provisioning_state: Current provisioning state of the virtual machine. Possible values + include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Locked". + :vartype provisioning_state: str or ~azure.mgmt.labservices.models.ProvisioningState + :ivar state: The current state of the virtual machine. Possible values include: "Stopped", + "Starting", "Running", "Stopping", "ResettingPassword", "Reimaging", "Redeploying". + :vartype state: str or ~azure.mgmt.labservices.models.VirtualMachineState + :ivar connection_profile: Profile for information about connecting to the virtual machine. + :vartype connection_profile: ~azure.mgmt.labservices.models.VirtualMachineConnectionProfile + :ivar claimed_by_user_id: The lab user ID (not the PUID!) of who claimed the virtual machine. + :vartype claimed_by_user_id: str + :ivar vm_type: The type of this VM resource. Possible values include: "User", "Template". + :vartype vm_type: str or ~azure.mgmt.labservices.models.VirtualMachineType """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'email': {'readonly': True}, - 'family_name': {'readonly': True}, - 'given_name': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'total_usage': {'readonly': True}, - 'latest_operation_result': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'state': {'readonly': True}, + 'connection_profile': {'readonly': True}, + 'claimed_by_user_id': {'readonly': True}, + 'vm_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}'}, - 'email': {'key': 'properties.email', 'type': 'str'}, - 'family_name': {'key': 'properties.familyName', 'type': 'str'}, - 'given_name': {'key': 'properties.givenName', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'total_usage': {'key': 'properties.totalUsage', 'type': 'duration'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, - 'latest_operation_result': {'key': 'properties.latestOperationResult', 'type': 'LatestOperationResult'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'connection_profile': {'key': 'properties.connectionProfile', 'type': 'VirtualMachineConnectionProfile'}, + 'claimed_by_user_id': {'key': 'properties.claimedByUserId', 'type': 'str'}, + 'vm_type': {'key': 'properties.vmType', 'type': 'str'}, } def __init__( self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, **kwargs ): - super(User, self).__init__(location=location, tags=tags, **kwargs) - self.email = None - self.family_name = None - self.given_name = None - self.tenant_id = None - self.total_usage = None - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier - self.latest_operation_result = None - + """ + """ + super(VirtualMachine, self).__init__(**kwargs) + self.system_data = None + self.provisioning_state = None + self.state = None + self.connection_profile = None + self.claimed_by_user_id = None + self.vm_type = None -class UserFragment(Resource): - """The User registered to a lab. - Variables are only populated by the server, and will be ignored when sending a request. +class VirtualMachineAdditionalCapabilities(msrest.serialization.Model): + """The additional capabilities for a lab VM. - :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 provisioning_state: The provisioning status of the resource. - :type provisioning_state: str - :param unique_identifier: The unique immutable identifier of a resource (Guid). - :type unique_identifier: str + :ivar install_gpu_drivers: Flag to pre-install dedicated GPU drivers. Possible values include: + "Enabled", "Disabled". + :vartype install_gpu_drivers: str or ~azure.mgmt.labservices.models.EnableState """ - _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}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'unique_identifier': {'key': 'properties.uniqueIdentifier', 'type': 'str'}, + 'install_gpu_drivers': {'key': 'installGpuDrivers', 'type': 'str'}, } def __init__( self, *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[str] = None, - unique_identifier: Optional[str] = None, + install_gpu_drivers: Optional[Union[str, "EnableState"]] = None, **kwargs ): - super(UserFragment, self).__init__(location=location, tags=tags, **kwargs) - self.provisioning_state = provisioning_state - self.unique_identifier = unique_identifier + """ + :keyword install_gpu_drivers: Flag to pre-install dedicated GPU drivers. Possible values + include: "Enabled", "Disabled". + :paramtype install_gpu_drivers: str or ~azure.mgmt.labservices.models.EnableState + """ + super(VirtualMachineAdditionalCapabilities, self).__init__(**kwargs) + self.install_gpu_drivers = install_gpu_drivers -class VirtualMachineDetails(msrest.serialization.Model): - """Details of the backing virtual machine. +class VirtualMachineConnectionProfile(msrest.serialization.Model): + """The connection information for the virtual machine. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the Dtl VM. - :vartype provisioning_state: str - :ivar rdp_authority: Connection information for Windows. - :vartype rdp_authority: str - :ivar ssh_authority: Connection information for Linux. - :vartype ssh_authority: str - :ivar private_ip_address: PrivateIp address of the compute VM. + :ivar private_ip_address: The private IP address of the virtual machine. :vartype private_ip_address: str - :ivar user_name: Compute VM login user name. - :vartype user_name: str - :ivar last_known_power_state: Last known compute power state captured in DTL. - :vartype last_known_power_state: str + :ivar ssh_authority: Port and host name separated by semicolon for connecting via SSH protocol + to the virtual machine. + :vartype ssh_authority: str + :ivar ssh_in_browser_url: URL for connecting via SSH protocol to the virtual machine in + browser. + :vartype ssh_in_browser_url: str + :ivar rdp_authority: Port and host name separated by semicolon for connecting via RDP protocol + to the virtual machine. + :vartype rdp_authority: str + :ivar rdp_in_browser_url: URL for connecting via RDP protocol to the virtual machine in + browser. + :vartype rdp_in_browser_url: str + :ivar admin_username: The username used to log on to the virtual machine as admin. + :vartype admin_username: str + :ivar non_admin_username: The username used to log on to the virtual machine as non-admin, if + one exists. + :vartype non_admin_username: str """ _validation = { - 'provisioning_state': {'readonly': True}, - 'rdp_authority': {'readonly': True}, - 'ssh_authority': {'readonly': True}, 'private_ip_address': {'readonly': True}, - 'user_name': {'readonly': True}, - 'last_known_power_state': {'readonly': True}, + 'ssh_authority': {'readonly': True}, + 'ssh_in_browser_url': {'readonly': True, 'max_length': 2000, 'min_length': 3}, + 'rdp_authority': {'readonly': True}, + 'rdp_in_browser_url': {'readonly': True, 'max_length': 2000, 'min_length': 3}, + 'admin_username': {'readonly': True}, + 'non_admin_username': {'readonly': True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'last_known_power_state': {'key': 'lastKnownPowerState', 'type': 'str'}, + 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, + 'ssh_in_browser_url': {'key': 'sshInBrowserUrl', 'type': 'str'}, + 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, + 'rdp_in_browser_url': {'key': 'rdpInBrowserUrl', 'type': 'str'}, + 'admin_username': {'key': 'adminUsername', 'type': 'str'}, + 'non_admin_username': {'key': 'nonAdminUsername', 'type': 'str'}, } def __init__( self, **kwargs ): - super(VirtualMachineDetails, self).__init__(**kwargs) - self.provisioning_state = None - self.rdp_authority = None - self.ssh_authority = None + """ + """ + super(VirtualMachineConnectionProfile, self).__init__(**kwargs) self.private_ip_address = None - self.user_name = None - self.last_known_power_state = None + self.ssh_authority = None + self.ssh_in_browser_url = None + self.rdp_authority = None + self.rdp_in_browser_url = None + self.admin_username = None + self.non_admin_username = None -class VmStateDetails(msrest.serialization.Model): - """Details about the state of the reference virtual machine. +class VirtualMachineProfile(msrest.serialization.Model): + """The base virtual machine configuration for a lab. Variables are only populated by the server, and will be ignored when sending a request. - :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 power_state: The power state of the reference virtual machine. - :vartype power_state: str - :ivar last_known_power_state: Last known compute power state captured in DTL. - :vartype last_known_power_state: str + All required parameters must be populated in order to send to Azure. + + :ivar create_option: Required. Indicates what lab virtual machines are created from. Possible + values include: "Image", "TemplateVM". + :vartype create_option: str or ~azure.mgmt.labservices.models.CreateOption + :ivar image_reference: Required. The image configuration for lab virtual machines. + :vartype image_reference: ~azure.mgmt.labservices.models.ImageReference + :ivar os_type: The OS type of the image. Possible values include: "Windows", "Linux". + :vartype os_type: str or ~azure.mgmt.labservices.models.OsType + :ivar sku: Required. The SKU for the lab. Defines the type of virtual machines used in the lab. + :vartype sku: ~azure.mgmt.labservices.models.Sku + :ivar additional_capabilities: Additional VM capabilities. + :vartype additional_capabilities: + ~azure.mgmt.labservices.models.VirtualMachineAdditionalCapabilities + :ivar usage_quota: Required. The initial quota alloted to each lab user. Must be a time span + between 0 and 9999 hours. + :vartype usage_quota: ~datetime.timedelta + :ivar use_shared_password: Enabling this option will use the same password for all user VMs. + Possible values include: "Enabled", "Disabled". + :vartype use_shared_password: str or ~azure.mgmt.labservices.models.EnableState + :ivar admin_user: Required. Credentials for the admin user on the VM. + :vartype admin_user: ~azure.mgmt.labservices.models.Credentials + :ivar non_admin_user: Credentials for the non-admin user on the VM, if one exists. + :vartype non_admin_user: ~azure.mgmt.labservices.models.Credentials """ _validation = { - 'rdp_authority': {'readonly': True}, - 'ssh_authority': {'readonly': True}, - 'power_state': {'readonly': True}, - 'last_known_power_state': {'readonly': True}, + 'create_option': {'required': True}, + 'image_reference': {'required': True}, + 'os_type': {'readonly': True}, + 'sku': {'required': True}, + 'usage_quota': {'required': True}, + 'admin_user': {'required': True}, } _attribute_map = { - 'rdp_authority': {'key': 'rdpAuthority', 'type': 'str'}, - 'ssh_authority': {'key': 'sshAuthority', 'type': 'str'}, - 'power_state': {'key': 'powerState', 'type': 'str'}, - 'last_known_power_state': {'key': 'lastKnownPowerState', 'type': 'str'}, + 'create_option': {'key': 'createOption', 'type': 'str'}, + 'image_reference': {'key': 'imageReference', 'type': 'ImageReference'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'additional_capabilities': {'key': 'additionalCapabilities', 'type': 'VirtualMachineAdditionalCapabilities'}, + 'usage_quota': {'key': 'usageQuota', 'type': 'duration'}, + 'use_shared_password': {'key': 'useSharedPassword', 'type': 'str'}, + 'admin_user': {'key': 'adminUser', 'type': 'Credentials'}, + 'non_admin_user': {'key': 'nonAdminUser', 'type': 'Credentials'}, } def __init__( self, - **kwargs - ): - super(VmStateDetails, self).__init__(**kwargs) - self.rdp_authority = None - self.ssh_authority = None - self.power_state = None - self.last_known_power_state = None + *, + create_option: Union[str, "CreateOption"], + image_reference: "ImageReference", + sku: "Sku", + usage_quota: datetime.timedelta, + admin_user: "Credentials", + additional_capabilities: Optional["VirtualMachineAdditionalCapabilities"] = None, + use_shared_password: Optional[Union[str, "EnableState"]] = None, + non_admin_user: Optional["Credentials"] = None, + **kwargs + ): + """ + :keyword create_option: Required. Indicates what lab virtual machines are created from. + Possible values include: "Image", "TemplateVM". + :paramtype create_option: str or ~azure.mgmt.labservices.models.CreateOption + :keyword image_reference: Required. The image configuration for lab virtual machines. + :paramtype image_reference: ~azure.mgmt.labservices.models.ImageReference + :keyword sku: Required. The SKU for the lab. Defines the type of virtual machines used in the + lab. + :paramtype sku: ~azure.mgmt.labservices.models.Sku + :keyword additional_capabilities: Additional VM capabilities. + :paramtype additional_capabilities: + ~azure.mgmt.labservices.models.VirtualMachineAdditionalCapabilities + :keyword usage_quota: Required. The initial quota alloted to each lab user. Must be a time span + between 0 and 9999 hours. + :paramtype usage_quota: ~datetime.timedelta + :keyword use_shared_password: Enabling this option will use the same password for all user VMs. + Possible values include: "Enabled", "Disabled". + :paramtype use_shared_password: str or ~azure.mgmt.labservices.models.EnableState + :keyword admin_user: Required. Credentials for the admin user on the VM. + :paramtype admin_user: ~azure.mgmt.labservices.models.Credentials + :keyword non_admin_user: Credentials for the non-admin user on the VM, if one exists. + :paramtype non_admin_user: ~azure.mgmt.labservices.models.Credentials + """ + super(VirtualMachineProfile, self).__init__(**kwargs) + self.create_option = create_option + self.image_reference = image_reference + self.os_type = None + self.sku = sku + self.additional_capabilities = additional_capabilities + self.usage_quota = usage_quota + self.use_shared_password = use_shared_password + self.admin_user = admin_user + self.non_admin_user = non_admin_user diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/__init__.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/__init__.py index bfdfe669911b..f4c911b36ab4 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/__init__.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/__init__.py @@ -6,24 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._provider_operations_operations import ProviderOperationsOperations -from ._global_users_operations import GlobalUsersOperations -from ._lab_accounts_operations import LabAccountsOperations +from ._images_operations import ImagesOperations +from ._lab_plans_operations import LabPlansOperations from ._operations import Operations -from ._gallery_images_operations import GalleryImagesOperations from ._labs_operations import LabsOperations -from ._environment_settings_operations import EnvironmentSettingsOperations -from ._environments_operations import EnvironmentsOperations +from ._operation_results_operations import OperationResultsOperations +from ._schedules_operations import SchedulesOperations from ._users_operations import UsersOperations +from ._virtual_machines_operations import VirtualMachinesOperations +from ._usages_operations import UsagesOperations +from ._skus_operations import SkusOperations __all__ = [ - 'ProviderOperationsOperations', - 'GlobalUsersOperations', - 'LabAccountsOperations', + 'ImagesOperations', + 'LabPlansOperations', 'Operations', - 'GalleryImagesOperations', 'LabsOperations', - 'EnvironmentSettingsOperations', - 'EnvironmentsOperations', + 'OperationResultsOperations', + 'SchedulesOperations', 'UsersOperations', + 'VirtualMachinesOperations', + 'UsagesOperations', + 'SkusOperations', ] diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_environment_settings_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_environment_settings_operations.py deleted file mode 100644 index 75e891961d89..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_environment_settings_operations.py +++ /dev/null @@ -1,951 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -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.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -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]] - -class EnvironmentSettingsOperations(object): - """EnvironmentSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name, # type: str - lab_account_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.ResponseWithContinuationEnvironmentSetting"] - """List environment setting in a given lab. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param expand: Specify the $expand query. Example: 'properties($select=publishingState)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationEnvironmentSetting or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationEnvironmentSetting] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationEnvironmentSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationEnvironmentSetting', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings'} # type: ignore - - def get( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.EnvironmentSetting" - """Get environment setting. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param expand: Specify the $expand query. Example: 'properties($select=publishingState)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnvironmentSetting, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.EnvironmentSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnvironmentSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EnvironmentSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - def _create_or_update_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_setting, # type: "_models.EnvironmentSetting" - **kwargs # type: Any - ): - # type: (...) -> "_models.EnvironmentSetting" - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnvironmentSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_setting, 'EnvironmentSetting') - 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 - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('EnvironmentSetting', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('EnvironmentSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - def begin_create_or_update( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_setting, # type: "_models.EnvironmentSetting" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.EnvironmentSetting"] - """Create or replace an existing Environment Setting. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_setting: Represents settings of an environment, from which environment - instances would be created. - :type environment_setting: ~azure.mgmt.labservices.models.EnvironmentSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 EnvironmentSetting or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.labservices.models.EnvironmentSetting] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnvironmentSetting"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_setting=environment_setting, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('EnvironmentSetting', 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - def _delete_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = self._client.delete(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 [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - def begin_delete( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Delete environment setting. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - def update( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_setting, # type: "_models.EnvironmentSettingFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.EnvironmentSetting" - """Modify properties of environment setting. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_setting: Represents settings of an environment, from which environment - instances would be created. - :type environment_setting: ~azure.mgmt.labservices.models.EnvironmentSettingFragment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnvironmentSetting, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.EnvironmentSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnvironmentSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_setting, 'EnvironmentSettingFragment') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EnvironmentSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}'} # type: ignore - - def claim_any( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Claims a random environment for a user in an environment settings. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.claim_any.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - claim_any.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/claimAny'} # type: ignore - - def publish( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - publish_payload, # type: "_models.PublishPayload" - **kwargs # type: Any - ): - # type: (...) -> None - """Provisions/deprovisions required resources for an environment setting based on current state of - the lab/environment setting. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param publish_payload: Payload for Publish operation on EnvironmentSetting. - :type publish_payload: ~azure.mgmt.labservices.models.PublishPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.publish.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(publish_payload, 'PublishPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/publish'} # type: ignore - - def _start_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = self._client.post(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/start'} # type: ignore - - def begin_start( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Starts a template by starting all resources inside the template. This operation can take a - while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._start_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/start'} # type: ignore - - def _stop_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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 = self._client.post(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/stop'} # type: ignore - - def begin_stop( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Starts a template by starting all resources inside the template. This operation can take a - while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._stop_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/stop'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_environments_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_environments_operations.py deleted file mode 100644 index 67cd96bf41f0..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_environments_operations.py +++ /dev/null @@ -1,993 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -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.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -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]] - -class EnvironmentsOperations(object): - """EnvironmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_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.ResponseWithContinuationEnvironment"] - """List environments in a given environment setting. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param expand: Specify the $expand query. Example: 'properties($expand=networkInterface)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationEnvironment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationEnvironment] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationEnvironment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationEnvironment', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments'} # type: ignore - - def get( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Environment" - """Get environment. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :param expand: Specify the $expand query. Example: 'properties($expand=networkInterface)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Environment, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.Environment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Environment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Environment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - environment, # type: "_models.Environment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Environment" - """Create or replace an existing Environment. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :param environment: Represents an environment instance. - :type environment: ~azure.mgmt.labservices.models.Environment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Environment, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.Environment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Environment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment, 'Environment') - 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 - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Environment', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Environment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - def _delete_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = self._client.delete(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 [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - def begin_delete( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Delete environment. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_name=environment_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - def update( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - environment, # type: "_models.EnvironmentFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Environment" - """Modify properties of environments. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :param environment: Represents an environment instance. - :type environment: ~azure.mgmt.labservices.models.EnvironmentFragment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Environment, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.Environment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Environment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment, 'EnvironmentFragment') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Environment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}'} # type: ignore - - def claim( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Claims the environment and assigns it to the user. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.claim.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - claim.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/claim'} # type: ignore - - def _reset_password_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - reset_password_payload, # type: "_models.ResetPasswordPayload" - **kwargs # type: Any - ): - # type: (...) -> 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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._reset_password_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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(reset_password_payload, 'ResetPasswordPayload') - 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 - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _reset_password_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/resetPassword'} # type: ignore - - def begin_reset_password( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - reset_password_payload, # type: "_models.ResetPasswordPayload" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Resets the user password on an environment This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_name: str - :param reset_password_payload: Represents the payload for resetting passwords. - :type reset_password_payload: ~azure.mgmt.labservices.models.ResetPasswordPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._reset_password_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_name=environment_name, - reset_password_payload=reset_password_payload, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_reset_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/resetPassword'} # type: ignore - - def _start_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = self._client.post(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/start'} # type: ignore - - def begin_start( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Starts an environment by starting all resources inside the environment. This operation can take - a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._start_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_name=environment_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/start'} # type: ignore - - def _stop_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_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 = self._client.post(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/stop'} # type: ignore - - def begin_stop( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - environment_setting_name, # type: str - environment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Stops an environment by stopping all resources inside the environment This operation can take a - while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param environment_setting_name: The name of the environment Setting. - :type environment_setting_name: str - :param environment_name: The name of the environment. - :type environment_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._stop_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - lab_name=lab_name, - environment_setting_name=environment_setting_name, - environment_name=environment_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'environmentSettingName': self._serialize.url("environment_setting_name", environment_setting_name, 'str'), - 'environmentName': self._serialize.url("environment_name", environment_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/stop'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_gallery_images_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_gallery_images_operations.py deleted file mode 100644 index 3b639e9c283a..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_gallery_images_operations.py +++ /dev/null @@ -1,415 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -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.mgmt.core.exceptions import ARMErrorFormat - -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]] - -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name, # type: str - lab_account_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.ResponseWithContinuationGalleryImage"] - """List gallery images in a given lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param expand: Specify the $expand query. Example: 'properties($select=author)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationGalleryImage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationGalleryImage] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationGalleryImage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationGalleryImage', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages'} # type: ignore - - def get( - self, - resource_group_name, # type: str - lab_account_name, # type: str - gallery_image_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.GalleryImage" - """Get gallery image. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param gallery_image_name: The name of the gallery Image. - :type gallery_image_name: str - :param expand: Specify the $expand query. Example: 'properties($select=author)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GalleryImage, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GalleryImage - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'galleryImageName': self._serialize.url("gallery_image_name", gallery_image_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 = 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GalleryImage', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - lab_account_name, # type: str - gallery_image_name, # type: str - gallery_image, # type: "_models.GalleryImage" - **kwargs # type: Any - ): - # type: (...) -> "_models.GalleryImage" - """Create or replace an existing Gallery Image. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param gallery_image_name: The name of the gallery Image. - :type gallery_image_name: str - :param gallery_image: Represents an image from the Azure Marketplace. - :type gallery_image: ~azure.mgmt.labservices.models.GalleryImage - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GalleryImage, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GalleryImage - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'galleryImageName': self._serialize.url("gallery_image_name", gallery_image_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(gallery_image, 'GalleryImage') - 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 - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('GalleryImage', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('GalleryImage', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - lab_account_name, # type: str - gallery_image_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete gallery image. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param gallery_image_name: The name of the gallery Image. - :type gallery_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'galleryImageName': self._serialize.url("gallery_image_name", gallery_image_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 = self._client.delete(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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}'} # type: ignore - - def update( - self, - resource_group_name, # type: str - lab_account_name, # type: str - gallery_image_name, # type: str - gallery_image, # type: "_models.GalleryImageFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.GalleryImage" - """Modify properties of gallery images. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param gallery_image_name: The name of the gallery Image. - :type gallery_image_name: str - :param gallery_image: Represents an image from the Azure Marketplace. - :type gallery_image: ~azure.mgmt.labservices.models.GalleryImageFragment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GalleryImage, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GalleryImage - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'galleryImageName': self._serialize.url("gallery_image_name", gallery_image_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(gallery_image, 'GalleryImageFragment') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GalleryImage', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_global_users_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_global_users_operations.py deleted file mode 100644 index ba694519a39f..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_global_users_operations.py +++ /dev/null @@ -1,814 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -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.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -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]] - -class GlobalUsersOperations(object): - """GlobalUsersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get_environment( - self, - user_name, # type: str - environment_operations_payload, # type: "_models.EnvironmentOperationsPayload" - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.GetEnvironmentResponse" - """Gets the virtual machine details. - - :param user_name: The name of the user. - :type user_name: str - :param environment_operations_payload: Represents payload for any Environment operations like - get, start, stop, connect. - :type environment_operations_payload: ~azure.mgmt.labservices.models.EnvironmentOperationsPayload - :param expand: Specify the $expand query. Example: 'properties($expand=environment)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetEnvironmentResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GetEnvironmentResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetEnvironmentResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_environment.metadata['url'] # type: ignore - path_format_arguments = { - '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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_operations_payload, 'EnvironmentOperationsPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GetEnvironmentResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_environment.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/getEnvironment'} # type: ignore - - def get_operation_batch_status( - self, - user_name, # type: str - operation_batch_status_payload, # type: "_models.OperationBatchStatusPayload" - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationBatchStatusResponse" - """Get batch operation status. - - :param user_name: The name of the user. - :type user_name: str - :param operation_batch_status_payload: Payload to get the status of an operation. - :type operation_batch_status_payload: ~azure.mgmt.labservices.models.OperationBatchStatusPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationBatchStatusResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.OperationBatchStatusResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationBatchStatusResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_operation_batch_status.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_batch_status_payload, 'OperationBatchStatusPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('OperationBatchStatusResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_operation_batch_status.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/getOperationBatchStatus'} # type: ignore - - def get_operation_status( - self, - user_name, # type: str - operation_status_payload, # type: "_models.OperationStatusPayload" - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationStatusResponse" - """Gets the status of long running operation. - - :param user_name: The name of the user. - :type user_name: str - :param operation_status_payload: Payload to get the status of an operation. - :type operation_status_payload: ~azure.mgmt.labservices.models.OperationStatusPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.OperationStatusResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_status_payload, 'OperationStatusPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('OperationStatusResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_operation_status.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/getOperationStatus'} # type: ignore - - def get_personal_preferences( - self, - user_name, # type: str - personal_preferences_operations_payload, # type: "_models.PersonalPreferencesOperationsPayload" - **kwargs # type: Any - ): - # type: (...) -> "_models.GetPersonalPreferencesResponse" - """Get personal preferences for a user. - - :param user_name: The name of the user. - :type user_name: str - :param personal_preferences_operations_payload: Represents payload for any Environment - operations like get, start, stop, connect. - :type personal_preferences_operations_payload: ~azure.mgmt.labservices.models.PersonalPreferencesOperationsPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetPersonalPreferencesResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GetPersonalPreferencesResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetPersonalPreferencesResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_personal_preferences.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(personal_preferences_operations_payload, 'PersonalPreferencesOperationsPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GetPersonalPreferencesResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_personal_preferences.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/getPersonalPreferences'} # type: ignore - - def list_environments( - self, - user_name, # type: str - list_environments_payload, # type: "_models.ListEnvironmentsPayload" - **kwargs # type: Any - ): - # type: (...) -> "_models.ListEnvironmentsResponse" - """List Environments for the user. - - :param user_name: The name of the user. - :type user_name: str - :param list_environments_payload: Represents the payload to list environments owned by a user. - :type list_environments_payload: ~azure.mgmt.labservices.models.ListEnvironmentsPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListEnvironmentsResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.ListEnvironmentsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListEnvironmentsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.list_environments.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(list_environments_payload, 'ListEnvironmentsPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ListEnvironmentsResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_environments.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/listEnvironments'} # type: ignore - - def list_labs( - self, - user_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ListLabsResponse" - """List labs for the user. - - :param user_name: The name of the user. - :type user_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListLabsResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.ListLabsResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListLabsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.list_labs.metadata['url'] # type: ignore - path_format_arguments = { - '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] - 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 = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ListLabsResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_labs.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/listLabs'} # type: ignore - - def register( - self, - user_name, # type: str - register_payload, # type: "_models.RegisterPayload" - **kwargs # type: Any - ): - # type: (...) -> None - """Register a user to a managed lab. - - :param user_name: The name of the user. - :type user_name: str - :param register_payload: Represents payload for Register action. - :type register_payload: ~azure.mgmt.labservices.models.RegisterPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(register_payload, 'RegisterPayload') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - register.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/register'} # type: ignore - - def _reset_password_initial( - self, - user_name, # type: str - reset_password_payload, # type: "_models.ResetPasswordPayload" - **kwargs # type: Any - ): - # type: (...) -> 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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._reset_password_initial.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(reset_password_payload, 'ResetPasswordPayload') - 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 - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _reset_password_initial.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/resetPassword'} # type: ignore - - def begin_reset_password( - self, - user_name, # type: str - reset_password_payload, # type: "_models.ResetPasswordPayload" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Resets the user password on an environment This operation can take a while to complete. - - :param user_name: The name of the user. - :type user_name: str - :param reset_password_payload: Represents the payload for resetting passwords. - :type reset_password_payload: ~azure.mgmt.labservices.models.ResetPasswordPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._reset_password_initial( - user_name=user_name, - reset_password_payload=reset_password_payload, - 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 = { - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_reset_password.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/resetPassword'} # type: ignore - - def _start_environment_initial( - self, - user_name, # type: str - environment_operations_payload, # type: "_models.EnvironmentOperationsPayload" - **kwargs # type: Any - ): - # type: (...) -> 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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._start_environment_initial.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_operations_payload, 'EnvironmentOperationsPayload') - 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 - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _start_environment_initial.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/startEnvironment'} # type: ignore - - def begin_start_environment( - self, - user_name, # type: str - environment_operations_payload, # type: "_models.EnvironmentOperationsPayload" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Starts an environment by starting all resources inside the environment. This operation can take - a while to complete. - - :param user_name: The name of the user. - :type user_name: str - :param environment_operations_payload: Represents payload for any Environment operations like - get, start, stop, connect. - :type environment_operations_payload: ~azure.mgmt.labservices.models.EnvironmentOperationsPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._start_environment_initial( - user_name=user_name, - environment_operations_payload=environment_operations_payload, - 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 = { - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start_environment.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/startEnvironment'} # type: ignore - - def _stop_environment_initial( - self, - user_name, # type: str - environment_operations_payload, # type: "_models.EnvironmentOperationsPayload" - **kwargs # type: Any - ): - # type: (...) -> 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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._stop_environment_initial.metadata['url'] # type: ignore - path_format_arguments = { - '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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(environment_operations_payload, 'EnvironmentOperationsPayload') - 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 - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _stop_environment_initial.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/stopEnvironment'} # type: ignore - - def begin_stop_environment( - self, - user_name, # type: str - environment_operations_payload, # type: "_models.EnvironmentOperationsPayload" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Stops an environment by stopping all resources inside the environment This operation can take a - while to complete. - - :param user_name: The name of the user. - :type user_name: str - :param environment_operations_payload: Represents payload for any Environment operations like - get, start, stop, connect. - :type environment_operations_payload: ~azure.mgmt.labservices.models.EnvironmentOperationsPayload - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._stop_environment_initial( - user_name=user_name, - environment_operations_payload=environment_operations_payload, - 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 = { - 'userName': self._serialize.url("user_name", user_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop_environment.metadata = {'url': '/providers/Microsoft.LabServices/users/{userName}/stopEnvironment'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_images_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_images_operations.py new file mode 100644 index 000000000000..ebd08332db8d --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_images_operations.py @@ -0,0 +1,492 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _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_lab_plan_request( + subscription_id: str, + resource_group_name: str, + lab_plan_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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_plan_name: str, + image_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + "imageName": _SERIALIZER.url("image_name", image_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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_plan_name: str, + image_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + "imageName": _SERIALIZER.url("image_name", image_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + lab_plan_name: str, + image_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + "imageName": _SERIALIZER.url("image_name", image_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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 ImagesOperations(object): + """ImagesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_lab_plan( + self, + resource_group_name: str, + lab_plan_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PagedImages"]: + """Gets all images. + + Gets all images from galleries attached to a lab plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedImages or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedImages] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedImages"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_lab_plan_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + filter=filter, + template_url=self.list_by_lab_plan.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_lab_plan_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + filter=filter, + 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("PagedImages", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_lab_plan.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + lab_plan_name: str, + image_name: str, + **kwargs: Any + ) -> "_models.Image": + """Gets an image. + + Gets an image resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param image_name: The image name. + :type image_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Image, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.Image + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + image_name=image_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Image', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + lab_plan_name: str, + image_name: str, + body: "_models.Image", + **kwargs: Any + ) -> "_models.Image": + """Updates an image via PUT. + + Updates an image resource via PUT. Creating new resources via PUT will not function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param image_name: The image name. + :type image_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.Image + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Image, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.Image + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'Image') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + image_name=image_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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Image', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}'} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + lab_plan_name: str, + image_name: str, + body: "_models.ImageUpdate", + **kwargs: Any + ) -> "_models.Image": + """Updates an image. + + Updates an image resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param image_name: The image name. + :type image_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.ImageUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Image, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.Image + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ImageUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + image_name=image_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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Image', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/images/{imageName}'} # type: ignore + diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_lab_accounts_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_lab_accounts_operations.py deleted file mode 100644 index f2ccd78178b2..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_lab_accounts_operations.py +++ /dev/null @@ -1,662 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -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.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -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]] - -class LabAccountsOperations(object): - """LabAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def 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.ResponseWithContinuationLabAccount"] - """List lab accounts in a subscription. - - :param expand: Specify the $expand query. Example: 'properties($expand=sizeConfiguration)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationLabAccount or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationLabAccount] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationLabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationLabAccount', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labaccounts'} # type: ignore - - 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.ResponseWithContinuationLabAccount"] - """List lab accounts in a resource group. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param expand: Specify the $expand query. Example: 'properties($expand=sizeConfiguration)'. - :type expand: str - :param filter: The filter to apply to the operation. - :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationLabAccount or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationLabAccount] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationLabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ResponseWithContinuationLabAccount', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts'} # type: ignore - - def get( - self, - resource_group_name, # type: str - lab_account_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.LabAccount" - """Get lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param expand: Specify the $expand query. Example: 'properties($expand=sizeConfiguration)'. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LabAccount, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.LabAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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 = 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('LabAccount', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_account, # type: "_models.LabAccount" - **kwargs # type: Any - ): - # type: (...) -> "_models.LabAccount" - """Create or replace an existing Lab Account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_account: Represents a lab account. - :type lab_account: ~azure.mgmt.labservices.models.LabAccount - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LabAccount, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.LabAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_account, 'LabAccount') - 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 - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('LabAccount', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('LabAccount', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - def _delete_initial( - self, - resource_group_name, # type: str - lab_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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 = self._client.delete(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 [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - def begin_delete( - self, - resource_group_name, # type: str - lab_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Delete lab account. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - lab_account_name=lab_account_name, - 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - def update( - self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_account, # type: "_models.LabAccountFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.LabAccount" - """Modify properties of lab accounts. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_account: Represents a lab account. - :type lab_account: ~azure.mgmt.labservices.models.LabAccountFragment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LabAccount, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.LabAccount - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LabAccount"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(lab_account, 'LabAccountFragment') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('LabAccount', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}'} # type: ignore - - def create_lab( - self, - resource_group_name, # type: str - lab_account_name, # type: str - create_lab_properties, # type: "_models.CreateLabProperties" - **kwargs # type: Any - ): - # type: (...) -> None - """Create a lab in a lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param create_lab_properties: Properties for creating a managed lab and a default environment - setting. - :type create_lab_properties: ~azure.mgmt.labservices.models.CreateLabProperties - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_lab.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_lab_properties, 'CreateLabProperties') - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - create_lab.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/createLab'} # type: ignore - - def get_regional_availability( - self, - resource_group_name, # type: str - lab_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GetRegionalAvailabilityResponse" - """Get regional availability information for each size category configured under a lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetRegionalAvailabilityResponse, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.GetRegionalAvailabilityResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetRegionalAvailabilityResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.get_regional_availability.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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 = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GetRegionalAvailabilityResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_regional_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/getRegionalAvailability'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_lab_plans_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_lab_plans_operations.py new file mode 100644 index 000000000000..c27a09849585 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_lab_plans_operations.py @@ -0,0 +1,977 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labPlans') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + lab_plan_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + lab_plan_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + lab_plan_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + lab_plan_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_save_image_request_initial( + subscription_id: str, + resource_group_name: str, + lab_plan_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/saveImage') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labPlanName": _SERIALIZER.url("lab_plan_name", lab_plan_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +class LabPlansOperations(object): + """LabPlansOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_subscription( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PagedLabPlans"]: + """Get all lab plans for a subscription. + + Returns a list of all lab plans within a subscription. + + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedLabPlans or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedLabPlans] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabPlans"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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("PagedLabPlans", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labPlans'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.PagedLabPlans"]: + """Get all lab plans for a subscription and resource group. + + Returns a list of all lab plans for a subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedLabPlans or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedLabPlans] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabPlans"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PagedLabPlans", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + lab_plan_name: str, + **kwargs: Any + ) -> "_models.LabPlan": + """Retrieves a Lab Plan resource. + + Retrieves the properties of a Lab Plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LabPlan, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.LabPlan + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LabPlan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.LabPlan", + **kwargs: Any + ) -> "_models.LabPlan": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'LabPlan') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.LabPlan", + **kwargs: Any + ) -> LROPoller["_models.LabPlan"]: + """Updates or creates a Lab Plan resource. + + Operation to create or update a Lab Plan resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.LabPlan + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LabPlan or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.labservices.models.LabPlan] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('LabPlan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.LabPlanUpdate", + **kwargs: Any + ) -> "_models.LabPlan": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'LabPlanUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('LabPlan', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.LabPlanUpdate", + **kwargs: Any + ) -> LROPoller["_models.LabPlan"]: + """Updates a Lab Plan resource. + + Operation to update a Lab Plan resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.LabPlanUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LabPlan or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.labservices.models.LabPlan] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabPlan"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('LabPlan', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + lab_plan_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + lab_plan_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a Lab Plan resource. + + Operation to delete a Lab Plan resource. Deleting a lab plan does not delete labs associated + with a lab plan, nor does it delete shared images added to a gallery via the lab plan + permission container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}'} # type: ignore + + def _save_image_initial( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.SaveImageBody", + **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', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'SaveImageBody') + + request = build_save_image_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + content_type=content_type, + json=_json, + template_url=self._save_image_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _save_image_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/saveImage'} # type: ignore + + + @distributed_trace + def begin_save_image( + self, + resource_group_name: str, + lab_plan_name: str, + body: "_models.SaveImageBody", + **kwargs: Any + ) -> LROPoller[None]: + """Save an image from a lab VM to the attached shared image gallery. + + Saves an image from a lab VM to the attached shared image gallery. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_plan_name: The name of the lab plan that uniquely identifies it within containing + resource group. Used in resource URIs and in UI. + :type lab_plan_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.SaveImageBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._save_image_initial( + resource_group_name=resource_group_name, + lab_plan_name=lab_plan_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_save_image.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labPlans/{labPlanName}/saveImage'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_labs_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_labs_operations.py index 9af18cad1287..1bc6c0b25292 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_labs_operations.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_labs_operations.py @@ -5,25 +5,324 @@ # 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, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_publish_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/publish') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_sync_group_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/syncGroup') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LabsOperations(object): """LabsOperations operations. @@ -47,79 +346,124 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list( + @distributed_trace + def list_by_subscription( self, - resource_group_name, # type: str - lab_account_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.ResponseWithContinuationLab"] - """List labs in a given lab account. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param expand: Specify the $expand query. Example: 'properties($select=maxUsersInLab)'. - :type expand: str + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PagedLabs"]: + """Get all labs for a subscription. + + Returns a list of all labs for a subscription. + :param filter: The filter to apply to the operation. :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationLab or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationLab] + :return: An iterator like instance of either PagedLabs or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedLabs] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationLab"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabs"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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("PagedLabs", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labs'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.PagedLabs"]: + """Get all labs for a subscription and resource group. + + Returns a list of all labs in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedLabs or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedLabs] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabs"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): if not next_link: - # 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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, + 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, + 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('ResponseWithContinuationLab', pipeline_response) + deserialized = self._deserialize("PagedLabs", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,34 +477,33 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs'} # type: ignore + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Lab" - """Get lab. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + **kwargs: Any + ) -> "_models.Lab": + """Get a lab resource. + + Returns the properties of a lab resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param expand: Specify the $expand query. Example: 'properties($select=maxUsersInLab)'. - :type expand: 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.labservices.models.Lab @@ -171,194 +514,346 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Lab', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + lab_name: str, + body: "_models.Lab", + **kwargs: Any + ) -> "_models.Lab": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'Lab') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_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) - 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, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Lab', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize('Lab', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Lab', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('Lab', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore - def create_or_update( + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - lab, # type: "_models.Lab" - **kwargs # type: Any - ): - # type: (...) -> "_models.Lab" - """Create or replace an existing Lab. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + body: "_models.Lab", + **kwargs: Any + ) -> LROPoller["_models.Lab"]: + """Create or update a lab resource. + + Operation to create or update a lab resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param lab: Represents a lab. - :type lab: ~azure.mgmt.labservices.models.Lab + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.Lab :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.labservices.models.Lab + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Lab or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.labservices.models.Lab] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Lab', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + lab_name: str, + body: "_models.LabUpdate", + **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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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(body, 'LabUpdate') - # 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Lab', pipeline_response) - if response.status_code == 201: + if response.status_code == 202: deserialized = self._deserialize('Lab', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + lab_name: str, + body: "_models.LabUpdate", + **kwargs: Any + ) -> LROPoller["_models.Lab"]: + """Update a lab resource. + + Operation to update a lab resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.LabUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Lab or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.labservices.models.Lab] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Lab', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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, + 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 - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Delete lab. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a lab resource. + + Operation to delete a lab resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -368,27 +863,18 @@ def begin_delete( if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, - lab_account_name=lab_account_name, lab_name=lab_name, 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -400,203 +886,204 @@ 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.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore - def update( + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}'} # type: ignore + + def _publish_initial( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - lab, # type: "_models.LabFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Lab" - """Modify properties of labs. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param lab: Represents a lab. - :type lab: ~azure.mgmt.labservices.models.LabFragment - :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.labservices.models.Lab - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Lab"] + resource_group_name: str, + lab_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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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') + + request = build_publish_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + template_url=self._publish_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, '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 - 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('Lab', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}'} # type: ignore + _publish_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/publish'} # type: ignore - def add_users( + + @distributed_trace + def begin_publish( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - add_users_payload, # type: "_models.AddUsersPayload" - **kwargs # type: Any - ): - # type: (...) -> None - """Add users to a lab. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Publish or re-publish a lab. + + Publish or re-publish a lab. This will create or update all lab resources, such as virtual + machines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param add_users_payload: Payload for Add Users operation on a Lab. - :type add_users_payload: ~azure.mgmt.labservices.models.AddUsersPayload :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._publish_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/publish'} # type: ignore + + def _sync_group_initial( + self, + resource_group_name: str, + lab_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-10-15" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.add_users.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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') + + request = build_sync_group_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + template_url=self._sync_group_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(add_users_payload, 'AddUsersPayload') - 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 - 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) if cls: return cls(pipeline_response, None, {}) - add_users.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/addUsers'} # type: ignore + _sync_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/syncGroup'} # type: ignore - def register( + + @distributed_trace + def begin_sync_group( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Register to managed lab. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Manually sync the lab group. + + Action used to manually kick off an AAD group sync job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-15" - accept = "application/json" - - # Construct URL - url = self.register.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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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') + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._sync_group_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - register.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/register'} # type: ignore + begin_sync_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/syncGroup'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_operation_results_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_operation_results_operations.py new file mode 100644 index 000000000000..d9dad6fa52a8 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_operation_results_operations.py @@ -0,0 +1,132 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, 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 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]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + operation_result_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/operationResults/{operationResultId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "operationResultId": _SERIALIZER.url("operation_result_id", operation_result_id, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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 OperationResultsOperations(object): + """OperationResultsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + operation_result_id: str, + **kwargs: Any + ) -> Optional["_models.OperationResult"]: + """Get an azure operation result. + + Returns an azure operation result. + + :param operation_result_id: The operation result ID / name. + :type operation_result_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationResult, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.OperationResult or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + operation_result_id=operation_result_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/operationResults/{operationResultId}'} # type: ignore + diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_operations.py index 69a09d7395cc..baf0840bc06c 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_operations.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_operations.py @@ -5,22 +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, 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 = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.LabServices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -44,61 +72,66 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def get( + @distributed_trace + def list( self, - location_name, # type: str - operation_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationResult" - """Get operation. - - :param location_name: The name of the location. - :type location_name: str - :param operation_name: The name of the operation. - :type operation_name: str + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """Get all operations. + + Returns a list of all operations. + :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationResult, or the result of cls(response) - :rtype: ~azure.mgmt.labservices.models.OperationResult + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'operationName': self._serialize.url("operation_name", operation_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 = 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]: - 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 cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/locations/{locationName}/operations/{operationName}'} # type: ignore + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.LabServices/operations'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_provider_operations_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_provider_operations_operations.py deleted file mode 100644 index 85461507fa6b..000000000000 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_provider_operations_operations.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -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.mgmt.core.exceptions import ARMErrorFormat - -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]] - -class ProviderOperationsOperations(object): - """ProviderOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.labservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> 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) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ProviderOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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 = 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) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.LabServices/operations'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_schedules_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_schedules_operations.py new file mode 100644 index 000000000000..44748708fa03 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_schedules_operations.py @@ -0,0 +1,644 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_lab_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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, + schedule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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, + schedule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + schedule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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_delete_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + schedule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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 SchedulesOperations(object): + """SchedulesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_lab( + self, + resource_group_name: str, + lab_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PagedSchedules"]: + """Get all schedules for a lab. + + Returns a list of all schedules for a lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedSchedules or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedSchedules] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedSchedules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + template_url=self.list_by_lab.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + 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("PagedSchedules", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_lab.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + **kwargs: Any + ) -> "_models.Schedule": + """Get a lab Schedule. + + Returns the properties of a lab Schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param schedule_name: The name of the schedule that uniquely identifies it within containing + lab. Used in resource URIs. + :type schedule_name: 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.labservices.models.Schedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Schedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + body: "_models.Schedule", + **kwargs: Any + ) -> "_models.Schedule": + """Create or update a lab schedule. + + Operation to create or update a lab schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param schedule_name: The name of the schedule that uniquely identifies it within containing + lab. Used in resource URIs. + :type schedule_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.Schedule + :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.labservices.models.Schedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'Schedule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Schedule', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Schedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + body: "_models.ScheduleUpdate", + **kwargs: Any + ) -> "_models.Schedule": + """Update a lab schedule. + + Operation to update a lab schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param schedule_name: The name of the schedule that uniquely identifies it within containing + lab. Used in resource URIs. + :type schedule_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.ScheduleUpdate + :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.labservices.models.Schedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ScheduleUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Schedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore + + + def _delete_initial( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + lab_name: str, + schedule_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a schedule resource. + + Operation to delete a schedule resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param schedule_name: The name of the schedule that uniquely identifies it within containing + lab. Used in resource URIs. + :type schedule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + schedule_name=schedule_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/schedules/{scheduleName}'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_skus_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_skus_operations.py new file mode 100644 index 000000000000..bec473144396 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_skus_operations.py @@ -0,0 +1,155 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _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, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/skus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 SkusOperations(object): + """SkusOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PagedLabServicesSkus"]: + """Gets all the Azure Lab Services resource SKUs. + + Returns a list of all the Azure Lab Services resource SKUs. + + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedLabServicesSkus or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedLabServicesSkus] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedLabServicesSkus"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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("PagedLabServicesSkus", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/skus'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_usages_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_usages_operations.py new file mode 100644 index 000000000000..fa66982130ca --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_usages_operations.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_location_request( + subscription_id: str, + location: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/locations/{location}/usages') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str', max_length=100, min_length=1, pattern=r'^[-\w\._]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 UsagesOperations(object): + """UsagesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_location( + self, + location: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ListUsagesResult"]: + """Gets the list of usages. + + Returns list of usage per SKU family for the specified subscription in the specified region. + + :param location: The location name. + :type location: str + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListUsagesResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ListUsagesResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + filter=filter, + template_url=self.list_by_location.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_location_request( + subscription_id=self._config.subscription_id, + location=location, + filter=filter, + 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("ListUsagesResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.LabServices/locations/{location}/usages'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_users_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_users_operations.py index 3b8f583f8844..85021251b5fb 100644 --- a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_users_operations.py +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_users_operations.py @@ -5,25 +5,279 @@ # 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_lab_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "userName": _SERIALIZER.url("user_name", user_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "userName": _SERIALIZER.url("user_name", user_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "userName": _SERIALIZER.url("user_name", user_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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_delete_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "userName": _SERIALIZER.url("user_name", user_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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_invite_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + user_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}/invite') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "userName": _SERIALIZER.url("user_name", user_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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 UsersOperations(object): """UsersOperations operations. @@ -47,83 +301,64 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list( + @distributed_trace + def list_by_lab( self, - resource_group_name, # type: str - lab_account_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.ResponseWithContinuationUser"] - """List users in a given lab. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PagedUsers"]: + """Get all users for a lab. + + Returns a list of all users for a lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param expand: Specify the $expand query. Example: 'properties($select=email)'. - :type expand: str :param filter: The filter to apply to the operation. :type filter: str - :param top: The maximum number of resources to return from the operation. - :type top: int - :param orderby: The ordering expression for the results, using OData notation. - :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 ResponseWithContinuationUser or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.ResponseWithContinuationUser] + :return: An iterator like instance of either PagedUsers or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedUsers] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResponseWithContinuationUser"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedUsers"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + template_url=self.list_by_lab.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_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + 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('ResponseWithContinuationUser', pipeline_response) + deserialized = self._deserialize("PagedUsers", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,37 +372,37 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users'} # type: ignore + list_by_lab.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - user_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.User" - """Get user. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + user_name: str, + **kwargs: Any + ) -> "_models.User": + """Get a lab user. + + Returns the properties of a lab user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param user_name: The name of the user. + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. :type user_name: str - :param expand: Specify the $expand query. Example: 'properties($select=email)'. - :type expand: 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.labservices.models.User @@ -178,204 +413,367 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_name, '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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('User', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.User", + **kwargs: Any + ) -> "_models.User": + cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # 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') + _json = self._serialize.body(body, 'User') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - 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, + 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) - 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, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize('User', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('User', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('User', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore - def create_or_update( + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - user_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> "_models.User" - """Create or replace an existing User. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.User", + **kwargs: Any + ) -> LROPoller["_models.User"]: + """Create or update a lab user. + + Operation to create or update a lab user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param user_name: The name of the user. + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. :type user_name: str - :param user: The User registered to a lab. - :type user: ~azure.mgmt.labservices.models.User + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.User :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.labservices.models.User + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.labservices.models.User] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('User', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.UserUpdate", + **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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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(body, 'UserUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('User', pipeline_response) - if response.status_code == 201: + if response.status_code == 202: deserialized = self._deserialize('User', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.UserUpdate", + **kwargs: Any + ) -> LROPoller["_models.User"]: + """Update a lab user. + + Operation to update a lab user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. + :type user_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.UserUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.labservices.models.User] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('User', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - user_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + lab_name: str, + user_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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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, + 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 - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - user_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Delete user. This operation can take a while to complete. - - :param resource_group_name: The name of the resource group. + resource_group_name: str, + lab_name: str, + user_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a user resource. + + Operation to delete a user resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. :type lab_name: str - :param user_name: The name of the user. + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. :type user_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -385,29 +783,19 @@ def begin_delete( if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, - lab_account_name=lab_account_name, lab_name=lab_name, user_name=user_name, 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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_name, 'str'), - 'labName': self._serialize.url("lab_name", lab_name, 'str'), - 'userName': self._serialize.url("user_name", user_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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -419,79 +807,123 @@ 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore - def update( + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}'} # type: ignore + + def _invite_initial( self, - resource_group_name, # type: str - lab_account_name, # type: str - lab_name, # type: str - user_name, # type: str - user, # type: "_models.UserFragment" - **kwargs # type: Any - ): - # type: (...) -> "_models.User" - """Modify properties of users. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param lab_account_name: The name of the lab Account. - :type lab_account_name: str - :param lab_name: The name of the lab. - :type lab_name: str - :param user_name: The name of the user. - :type user_name: str - :param user: The User registered to a lab. - :type user: ~azure.mgmt.labservices.models.UserFragment - :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.labservices.models.User - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.InviteBody", + **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-10-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'), - 'labAccountName': self._serialize.url("lab_account_name", lab_account_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] - 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(body, 'InviteBody') - # 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_invite_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + content_type=content_type, + json=_json, + template_url=self._invite_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, '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 - 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('User', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}'} # type: ignore + _invite_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}/invite'} # type: ignore + + + @distributed_trace + def begin_invite( + self, + resource_group_name: str, + lab_name: str, + user_name: str, + body: "_models.InviteBody", + **kwargs: Any + ) -> LROPoller[None]: + """Invite a user to a lab. + + Operation to invite a user to a lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param user_name: The name of the user that uniquely identifies it within containing lab. Used + in resource URIs. + :type user_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.InviteBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._invite_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + user_name=user_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_invite.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/users/{userName}/invite'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_virtual_machines_operations.py b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_virtual_machines_operations.py new file mode 100644 index 000000000000..a359b3419b91 --- /dev/null +++ b/sdk/labservices/azure-mgmt-labservices/azure/mgmt/labservices/operations/_virtual_machines_operations.py @@ -0,0 +1,1008 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_lab_request( + subscription_id: str, + resource_group_name: str, + lab_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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_start_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/start') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/stop') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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_reimage_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/reimage') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/redeploy') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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_reset_password_request_initial( + subscription_id: str, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-11-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/resetPassword') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "labName": _SERIALIZER.url("lab_name", lab_name, 'str', max_length=100, min_length=1), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str', max_length=100, min_length=1, pattern=r'^[-\w\\._\\(\\)]+$'), + } + + 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 VirtualMachinesOperations(object): + """VirtualMachinesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.labservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_lab( + self, + resource_group_name: str, + lab_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.PagedVirtualMachines"]: + """Get all virtual machines for a lab. + + Returns a list of all virtual machines for a lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param filter: The filter to apply to the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PagedVirtualMachines or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.labservices.models.PagedVirtualMachines] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PagedVirtualMachines"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + template_url=self.list_by_lab.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_lab_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + filter=filter, + 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("PagedVirtualMachines", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_lab.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> "_models.VirtualMachine": + """Get a lab virtual machine. + + Returns the properties for a lab virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachine, or the result of cls(response) + :rtype: ~azure.mgmt.labservices.models.VirtualMachine + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}'} # type: ignore + + + def _start_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/start'} # type: ignore + + + @distributed_trace + def begin_start( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Start a lab virtual machine. + + Action to start a lab virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/start'} # type: ignore + + def _stop_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/stop'} # type: ignore + + + @distributed_trace + def begin_stop( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Stop a lab virtual machine. + + Action to stop a lab virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._stop_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/stop'} # type: ignore + + def _reimage_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_reimage_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + template_url=self._reimage_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _reimage_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/reimage'} # type: ignore + + + @distributed_trace + def begin_reimage( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Re-image a lab virtual machine. + + Re-image a lab virtual machine. The virtual machine will be deleted and recreated using the + latest published snapshot of the reference environment of the lab. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._reimage_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_reimage.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/reimage'} # type: ignore + + def _redeploy_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_redeploy_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + template_url=self._redeploy_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _redeploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/redeploy'} # type: ignore + + + @distributed_trace + def begin_redeploy( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Redeploy a lab virtual machine to a different compute node. For troubleshooting connectivity. + + Action to redeploy a lab virtual machine to a different compute node. For troubleshooting + connectivity. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._redeploy_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_redeploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/redeploy'} # type: ignore + + def _reset_password_initial( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + body: "_models.ResetPasswordBody", + **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', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'ResetPasswordBody') + + request = build_reset_password_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + content_type=content_type, + json=_json, + template_url=self._reset_password_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _reset_password_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/resetPassword'} # type: ignore + + + @distributed_trace + def begin_reset_password( + self, + resource_group_name: str, + lab_name: str, + virtual_machine_name: str, + body: "_models.ResetPasswordBody", + **kwargs: Any + ) -> LROPoller[None]: + """Reset a lab virtual machine password. + + Resets a lab virtual machine password. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param lab_name: The name of the lab that uniquely identifies it within containing lab account. + Used in resource URIs. + :type lab_name: str + :param virtual_machine_name: The ID of the virtual machine that uniquely identifies it within + the containing lab. Used in resource URIs. + :type virtual_machine_name: str + :param body: The request body. + :type body: ~azure.mgmt.labservices.models.ResetPasswordBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._reset_password_initial( + resource_group_name=resource_group_name, + lab_name=lab_name, + virtual_machine_name=virtual_machine_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_reset_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LabServices/labs/{labName}/virtualMachines/{virtualMachineName}/resetPassword'} # type: ignore diff --git a/sdk/labservices/azure-mgmt-labservices/setup.py b/sdk/labservices/azure-mgmt-labservices/setup.py index b67928b28d7d..0e2348a46a63 100644 --- a/sdk/labservices/azure-mgmt-labservices/setup.py +++ b/sdk/labservices/azure-mgmt-labservices/setup.py @@ -68,7 +68,7 @@ install_requires=[ 'msrest>=0.6.21', 'azure-common~=1.1', - 'azure-mgmt-core>=1.2.0,<2.0.0', + 'azure-mgmt-core>=1.3.0,<2.0.0', ], python_requires=">=3.6", ) diff --git a/shared_requirements.txt b/shared_requirements.txt index fbf2d2e55c11..a5f90b1ee877 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -251,9 +251,11 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-streamanalytics azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-consumption msrest>=0.6.21 #override azure-mgmt-consumption azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-labservices msrest>=0.6.21 +#override azure-mgmt-labservices azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-synapse msrest>=0.6.21 #override azure-mgmt-synapse azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-botservice msrest>=0.6.21 #override azure-mgmt-botservice azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-web msrest>=0.6.21 -#override azure-mgmt-web azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-web azure-mgmt-core>=1.3.0,<2.0.0 \ No newline at end of file