From c2151f6ef911a072d795d149e181887db444ec3c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 9 Nov 2022 07:51:02 +0000 Subject: [PATCH] CodeGen from PR 21488 in Azure/azure-rest-api-specs Merge ba1cb99aa2907d1bb7e1c0ad51f28d804051ac7e into 7d6c14d986a67dca3451d7d92d8f6b9416d61fbf --- .../_meta.json | 12 +- .../mgmt/desktopvirtualization/__init__.py | 17 +- .../desktopvirtualization/_configuration.py | 66 +- .../_desktop_virtualization_api_client.py | 153 - .../_desktop_virtualization_mgmt_client.py | 148 + .../mgmt/desktopvirtualization/_metadata.json | 116 - .../mgmt/desktopvirtualization/_patch.py | 20 + .../desktopvirtualization/_serialization.py | 1970 +++++++ .../mgmt/desktopvirtualization/_vendor.py | 27 + .../desktopvirtualization/aio/__init__.py | 17 +- .../aio/_configuration.py | 63 +- .../aio/_desktop_virtualization_api_client.py | 146 - .../_desktop_virtualization_mgmt_client.py | 146 + .../mgmt/desktopvirtualization/aio/_patch.py | 20 + .../aio/operations/__init__.py | 36 +- .../_application_groups_operations.py | 722 ++- .../operations/_applications_operations.py | 654 ++- .../aio/operations/_desktops_operations.py | 408 +- .../aio/operations/_host_pools_operations.py | 794 ++- .../aio/operations/_msix_images_operations.py | 237 +- .../operations/_msix_packages_operations.py | 658 ++- .../aio/operations/_operations.py | 140 +- .../aio/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 578 --- .../_private_link_resources_operations.py | 190 - ...caling_plan_pooled_schedules_operations.py | 616 +++ .../operations/_scaling_plans_operations.py | 823 ++- .../operations/_session_hosts_operations.py | 501 +- .../_start_menu_items_operations.py | 162 +- .../operations/_user_sessions_operations.py | 689 ++- .../aio/operations/_workspaces_operations.py | 705 ++- .../desktopvirtualization/models/__init__.py | 428 +- ...sktop_virtualization_mgmt_client_enums.py} | 200 +- .../desktopvirtualization/models/_models.py | 3114 ----------- .../models/_models_py3.py | 4621 ++++++++++------- .../desktopvirtualization/models/_patch.py | 20 + .../operations/__init__.py | 36 +- .../_application_groups_operations.py | 976 +++- .../operations/_applications_operations.py | 888 +++- .../operations/_desktops_operations.py | 561 +- .../operations/_host_pools_operations.py | 1081 ++-- .../operations/_msix_images_operations.py | 282 +- .../operations/_msix_packages_operations.py | 890 +++- .../operations/_operations.py | 169 +- .../operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 590 --- .../_private_link_resources_operations.py | 196 - ...caling_plan_pooled_schedules_operations.py | 824 +++ .../operations/_scaling_plans_operations.py | 1126 ++-- .../operations/_session_hosts_operations.py | 708 ++- .../_start_menu_items_operations.py | 231 +- .../operations/_user_sessions_operations.py | 1008 +++- .../operations/_workspaces_operations.py | 938 +++- .../generated_samples/application_create.py | 54 + .../generated_samples/application_delete.py | 42 + .../generated_samples/application_get.py | 42 + .../application_group_create.py | 51 + .../application_group_delete.py | 41 + .../application_group_get.py | 41 + .../application_group_list.py | 39 + ...pplication_group_list_by_resource_group.py | 41 + .../application_groups_update.py | 41 + .../generated_samples/application_update.py | 42 + .../generated_samples/applications_list.py | 42 + .../generated_samples/desktop_get.py | 42 + .../generated_samples/desktop_list.py | 42 + .../generated_samples/desktop_update.py | 42 + .../generated_samples/host_pool_create.py | 71 + .../generated_samples/host_pool_delete.py | 41 + .../generated_samples/host_pool_get.py | 41 + .../generated_samples/host_pool_list.py | 39 + .../host_pool_list_by_resource_group.py | 41 + .../generated_samples/host_pool_update.py | 41 + ..._pools_retrieve_registration_token_post.py | 41 + .../generated_samples/msix_package_create.py | 73 + .../generated_samples/msix_package_delete.py | 42 + .../generated_samples/msix_package_get.py | 42 + .../generated_samples/msix_package_list.py | 42 + .../generated_samples/msix_package_update.py | 42 + .../operation_description_list.py | 39 + .../scaling_plan_list_by_host_pool.py | 42 + .../scaling_plan_pooled_schedules_create.py | 62 + .../scaling_plan_pooled_schedules_delete.py | 42 + .../scaling_plan_pooled_schedules_get.py | 42 + .../scaling_plan_pooled_schedules_list.py | 42 + .../scaling_plan_pooled_schedules_update.py | 42 + .../generated_samples/scaling_plans_create.py | 79 + .../generated_samples/scaling_plans_delete.py | 41 + .../generated_samples/scaling_plans_get.py | 41 + .../scaling_plans_list_by_resource_group.py | 41 + .../scaling_plans_list_by_subscription.py | 39 + .../generated_samples/scaling_plans_update.py | 41 + .../generated_samples/session_host_delete.py | 42 + .../generated_samples/session_host_get.py | 42 + .../generated_samples/session_host_list.py | 42 + .../generated_samples/session_host_update.py | 42 + .../generated_samples/start_menu_item_list.py | 42 + .../generated_samples/user_session_delete.py | 43 + .../user_session_disconnect_post.py | 43 + .../generated_samples/user_session_get.py | 43 + .../generated_samples/user_session_list.py | 43 + .../user_session_list_by_host_pool.py | 42 + .../user_session_send_message_post.py | 43 + .../generated_samples/workspace_create.py | 46 + .../generated_samples/workspace_delete.py | 41 + .../generated_samples/workspace_get.py | 41 + .../workspace_list_by_resource_group.py | 41 + .../workspace_list_by_subscription.py | 39 + .../generated_samples/workspace_update.py | 41 + 109 files changed, 20211 insertions(+), 12017 deletions(-) delete mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_desktop_virtualization_api_client.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_desktop_virtualization_mgmt_client.py delete mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_metadata.json create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_patch.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_serialization.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_vendor.py delete mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_desktop_virtualization_api_client.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_desktop_virtualization_mgmt_client.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_patch.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_patch.py delete mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_private_endpoint_connections_operations.py delete mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_private_link_resources_operations.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_scaling_plan_pooled_schedules_operations.py rename sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/{_desktop_virtualization_api_client_enums.py => _desktop_virtualization_mgmt_client_enums.py} (68%) delete mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_models.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_patch.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_patch.py delete mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_private_endpoint_connections_operations.py delete mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_private_link_resources_operations.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_scaling_plan_pooled_schedules_operations.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_create.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_create.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_list_by_resource_group.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_groups_update.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_update.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/applications_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_update.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_create.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_list_by_resource_group.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_update.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pools_retrieve_registration_token_post.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_create.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_update.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/operation_description_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_list_by_host_pool.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_create.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_update.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_create.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_list_by_resource_group.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_list_by_subscription.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_update.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_update.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/start_menu_item_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_disconnect_post.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_list.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_list_by_host_pool.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_send_message_post.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_create.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_delete.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_get.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_list_by_resource_group.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_list_by_subscription.py create mode 100644 sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_update.py diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/_meta.json b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/_meta.json index 64ddb3ce1e0a..53e2b0a0e037 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/_meta.json +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "commit": "e98b2f5e46ce0d70a939e7d646f6d52e8afe245d", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@6.2.1", + "@autorest/modelerfour@4.24.3" ], - "commit": "2b56c8a3da0e04aea6f6d80a9ac04741d1ae5904", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/desktopvirtualization/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/desktopvirtualization/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/desktopvirtualization/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/__init__.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/__init__.py index fcebd4b56540..af771328df80 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/__init__.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/__init__.py @@ -6,14 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._desktop_virtualization_api_client import DesktopVirtualizationAPIClient +from ._desktop_virtualization_mgmt_client import DesktopVirtualizationMgmtClient from ._version import VERSION __version__ = VERSION -__all__ = ['DesktopVirtualizationAPIClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DesktopVirtualizationMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_configuration.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_configuration.py index ffa93f1c794f..923651baef15 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_configuration.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_configuration.py @@ -6,66 +6,70 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +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 sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class DesktopVirtualizationAPIClientConfiguration(Configuration): - """Configuration for DesktopVirtualizationAPIClient. +class DesktopVirtualizationMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for DesktopVirtualizationMgmtClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-09". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DesktopVirtualizationMgmtClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-09-09") # type: Literal["2022-09-09"] + 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(DesktopVirtualizationAPIClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-03-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-desktopvirtualization/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-desktopvirtualization/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_desktop_virtualization_api_client.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_desktop_virtualization_api_client.py deleted file mode 100644 index 40177dec69db..000000000000 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_desktop_virtualization_api_client.py +++ /dev/null @@ -1,153 +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 azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import DesktopVirtualizationAPIClientConfiguration -from .operations import Operations -from .operations import WorkspacesOperations -from .operations import ScalingPlansOperations -from .operations import ApplicationGroupsOperations -from .operations import StartMenuItemsOperations -from .operations import ApplicationsOperations -from .operations import DesktopsOperations -from .operations import HostPoolsOperations -from .operations import UserSessionsOperations -from .operations import SessionHostsOperations -from .operations import MSIXPackagesOperations -from .operations import MsixImagesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from . import models - - -class DesktopVirtualizationAPIClient(object): - """DesktopVirtualizationAPIClient. - - :ivar operations: Operations operations - :vartype operations: desktop_virtualization_api_client.operations.Operations - :ivar workspaces: WorkspacesOperations operations - :vartype workspaces: desktop_virtualization_api_client.operations.WorkspacesOperations - :ivar scaling_plans: ScalingPlansOperations operations - :vartype scaling_plans: desktop_virtualization_api_client.operations.ScalingPlansOperations - :ivar application_groups: ApplicationGroupsOperations operations - :vartype application_groups: desktop_virtualization_api_client.operations.ApplicationGroupsOperations - :ivar start_menu_items: StartMenuItemsOperations operations - :vartype start_menu_items: desktop_virtualization_api_client.operations.StartMenuItemsOperations - :ivar applications: ApplicationsOperations operations - :vartype applications: desktop_virtualization_api_client.operations.ApplicationsOperations - :ivar desktops: DesktopsOperations operations - :vartype desktops: desktop_virtualization_api_client.operations.DesktopsOperations - :ivar host_pools: HostPoolsOperations operations - :vartype host_pools: desktop_virtualization_api_client.operations.HostPoolsOperations - :ivar user_sessions: UserSessionsOperations operations - :vartype user_sessions: desktop_virtualization_api_client.operations.UserSessionsOperations - :ivar session_hosts: SessionHostsOperations operations - :vartype session_hosts: desktop_virtualization_api_client.operations.SessionHostsOperations - :ivar msix_packages: MSIXPackagesOperations operations - :vartype msix_packages: desktop_virtualization_api_client.operations.MSIXPackagesOperations - :ivar msix_images: MsixImagesOperations operations - :vartype msix_images: desktop_virtualization_api_client.operations.MsixImagesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: desktop_virtualization_api_client.operations.PrivateEndpointConnectionsOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: desktop_virtualization_api_client.operations.PrivateLinkResourcesOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :param str base_url: Service URL - """ - - 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 = DesktopVirtualizationAPIClientConfiguration(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.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.workspaces = WorkspacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scaling_plans = ScalingPlansOperations( - self._client, self._config, self._serialize, self._deserialize) - self.application_groups = ApplicationGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.start_menu_items = StartMenuItemsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.applications = ApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.desktops = DesktopsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.host_pools = HostPoolsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.user_sessions = UserSessionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.session_hosts = SessionHostsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.msix_packages = MSIXPackagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.msix_images = MsixImagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> DesktopVirtualizationAPIClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_desktop_virtualization_mgmt_client.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_desktop_virtualization_mgmt_client.py new file mode 100644 index 000000000000..dd2e32a9e9a9 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_desktop_virtualization_mgmt_client.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import DesktopVirtualizationMgmtClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + ApplicationGroupsOperations, + ApplicationsOperations, + DesktopsOperations, + HostPoolsOperations, + MSIXPackagesOperations, + MsixImagesOperations, + Operations, + ScalingPlanPooledSchedulesOperations, + ScalingPlansOperations, + SessionHostsOperations, + StartMenuItemsOperations, + UserSessionsOperations, + WorkspacesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DesktopVirtualizationMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """DesktopVirtualizationMgmtClient. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.desktopvirtualization.operations.Operations + :ivar workspaces: WorkspacesOperations operations + :vartype workspaces: azure.mgmt.desktopvirtualization.operations.WorkspacesOperations + :ivar scaling_plans: ScalingPlansOperations operations + :vartype scaling_plans: azure.mgmt.desktopvirtualization.operations.ScalingPlansOperations + :ivar scaling_plan_pooled_schedules: ScalingPlanPooledSchedulesOperations operations + :vartype scaling_plan_pooled_schedules: + azure.mgmt.desktopvirtualization.operations.ScalingPlanPooledSchedulesOperations + :ivar application_groups: ApplicationGroupsOperations operations + :vartype application_groups: + azure.mgmt.desktopvirtualization.operations.ApplicationGroupsOperations + :ivar start_menu_items: StartMenuItemsOperations operations + :vartype start_menu_items: azure.mgmt.desktopvirtualization.operations.StartMenuItemsOperations + :ivar applications: ApplicationsOperations operations + :vartype applications: azure.mgmt.desktopvirtualization.operations.ApplicationsOperations + :ivar desktops: DesktopsOperations operations + :vartype desktops: azure.mgmt.desktopvirtualization.operations.DesktopsOperations + :ivar host_pools: HostPoolsOperations operations + :vartype host_pools: azure.mgmt.desktopvirtualization.operations.HostPoolsOperations + :ivar user_sessions: UserSessionsOperations operations + :vartype user_sessions: azure.mgmt.desktopvirtualization.operations.UserSessionsOperations + :ivar session_hosts: SessionHostsOperations operations + :vartype session_hosts: azure.mgmt.desktopvirtualization.operations.SessionHostsOperations + :ivar msix_packages: MSIXPackagesOperations operations + :vartype msix_packages: azure.mgmt.desktopvirtualization.operations.MSIXPackagesOperations + :ivar msix_images: MsixImagesOperations operations + :vartype msix_images: azure.mgmt.desktopvirtualization.operations.MsixImagesOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-09-09". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DesktopVirtualizationMgmtClientConfiguration( + 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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.scaling_plans = ScalingPlansOperations(self._client, self._config, self._serialize, self._deserialize) + self.scaling_plan_pooled_schedules = ScalingPlanPooledSchedulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_groups = ApplicationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.start_menu_items = StartMenuItemsOperations(self._client, self._config, self._serialize, self._deserialize) + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.desktops = DesktopsOperations(self._client, self._config, self._serialize, self._deserialize) + self.host_pools = HostPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_sessions = UserSessionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.session_hosts = SessionHostsOperations(self._client, self._config, self._serialize, self._deserialize) + self.msix_packages = MSIXPackagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.msix_images = MsixImagesOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :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: () -> DesktopVirtualizationMgmtClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_metadata.json b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_metadata.json deleted file mode 100644 index 904a9e59c437..000000000000 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_metadata.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "chosen_version": "2021-09-03-preview", - "total_api_version_list": ["2021-09-03-preview"], - "client": { - "name": "DesktopVirtualizationAPIClient", - "filename": "_desktop_virtualization_api_client", - "description": "DesktopVirtualizationAPIClient.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": false, - "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\": [\"DesktopVirtualizationAPIClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DesktopVirtualizationAPIClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "workspaces": "WorkspacesOperations", - "scaling_plans": "ScalingPlansOperations", - "application_groups": "ApplicationGroupsOperations", - "start_menu_items": "StartMenuItemsOperations", - "applications": "ApplicationsOperations", - "desktops": "DesktopsOperations", - "host_pools": "HostPoolsOperations", - "user_sessions": "UserSessionsOperations", - "session_hosts": "SessionHostsOperations", - "msix_packages": "MSIXPackagesOperations", - "msix_images": "MsixImagesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "private_link_resources": "PrivateLinkResourcesOperations" - } -} \ No newline at end of file diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_patch.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_serialization.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_vendor.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/_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/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/__init__.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/__init__.py index 3160c7b3c306..94f7d2931594 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/__init__.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/__init__.py @@ -6,5 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._desktop_virtualization_api_client import DesktopVirtualizationAPIClient -__all__ = ['DesktopVirtualizationAPIClient'] +from ._desktop_virtualization_mgmt_client import DesktopVirtualizationMgmtClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DesktopVirtualizationMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_configuration.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_configuration.py index b3c5015744c4..404cecf2fda1 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_configuration.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_configuration.py @@ -6,62 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys 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 ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class DesktopVirtualizationAPIClientConfiguration(Configuration): - """Configuration for DesktopVirtualizationAPIClient. +class DesktopVirtualizationMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for DesktopVirtualizationMgmtClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-09". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DesktopVirtualizationMgmtClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-09-09") # type: Literal["2022-09-09"] + 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(DesktopVirtualizationAPIClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-03-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-desktopvirtualization/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-desktopvirtualization/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_desktop_virtualization_api_client.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_desktop_virtualization_api_client.py deleted file mode 100644 index f0b1d0e9141c..000000000000 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_desktop_virtualization_api_client.py +++ /dev/null @@ -1,146 +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.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import DesktopVirtualizationAPIClientConfiguration -from .operations import Operations -from .operations import WorkspacesOperations -from .operations import ScalingPlansOperations -from .operations import ApplicationGroupsOperations -from .operations import StartMenuItemsOperations -from .operations import ApplicationsOperations -from .operations import DesktopsOperations -from .operations import HostPoolsOperations -from .operations import UserSessionsOperations -from .operations import SessionHostsOperations -from .operations import MSIXPackagesOperations -from .operations import MsixImagesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .. import models - - -class DesktopVirtualizationAPIClient(object): - """DesktopVirtualizationAPIClient. - - :ivar operations: Operations operations - :vartype operations: desktop_virtualization_api_client.aio.operations.Operations - :ivar workspaces: WorkspacesOperations operations - :vartype workspaces: desktop_virtualization_api_client.aio.operations.WorkspacesOperations - :ivar scaling_plans: ScalingPlansOperations operations - :vartype scaling_plans: desktop_virtualization_api_client.aio.operations.ScalingPlansOperations - :ivar application_groups: ApplicationGroupsOperations operations - :vartype application_groups: desktop_virtualization_api_client.aio.operations.ApplicationGroupsOperations - :ivar start_menu_items: StartMenuItemsOperations operations - :vartype start_menu_items: desktop_virtualization_api_client.aio.operations.StartMenuItemsOperations - :ivar applications: ApplicationsOperations operations - :vartype applications: desktop_virtualization_api_client.aio.operations.ApplicationsOperations - :ivar desktops: DesktopsOperations operations - :vartype desktops: desktop_virtualization_api_client.aio.operations.DesktopsOperations - :ivar host_pools: HostPoolsOperations operations - :vartype host_pools: desktop_virtualization_api_client.aio.operations.HostPoolsOperations - :ivar user_sessions: UserSessionsOperations operations - :vartype user_sessions: desktop_virtualization_api_client.aio.operations.UserSessionsOperations - :ivar session_hosts: SessionHostsOperations operations - :vartype session_hosts: desktop_virtualization_api_client.aio.operations.SessionHostsOperations - :ivar msix_packages: MSIXPackagesOperations operations - :vartype msix_packages: desktop_virtualization_api_client.aio.operations.MSIXPackagesOperations - :ivar msix_images: MsixImagesOperations operations - :vartype msix_images: desktop_virtualization_api_client.aio.operations.MsixImagesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: desktop_virtualization_api_client.aio.operations.PrivateEndpointConnectionsOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: desktop_virtualization_api_client.aio.operations.PrivateLinkResourcesOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :param str base_url: Service URL - """ - - 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 = DesktopVirtualizationAPIClientConfiguration(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.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.workspaces = WorkspacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scaling_plans = ScalingPlansOperations( - self._client, self._config, self._serialize, self._deserialize) - self.application_groups = ApplicationGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.start_menu_items = StartMenuItemsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.applications = ApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.desktops = DesktopsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.host_pools = HostPoolsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.user_sessions = UserSessionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.session_hosts = SessionHostsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.msix_packages = MSIXPackagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.msix_images = MsixImagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "DesktopVirtualizationAPIClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_desktop_virtualization_mgmt_client.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_desktop_virtualization_mgmt_client.py new file mode 100644 index 000000000000..5345dbf74851 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_desktop_virtualization_mgmt_client.py @@ -0,0 +1,146 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from .._serialization import Deserializer, Serializer +from ._configuration import DesktopVirtualizationMgmtClientConfiguration +from .operations import ( + ApplicationGroupsOperations, + ApplicationsOperations, + DesktopsOperations, + HostPoolsOperations, + MSIXPackagesOperations, + MsixImagesOperations, + Operations, + ScalingPlanPooledSchedulesOperations, + ScalingPlansOperations, + SessionHostsOperations, + StartMenuItemsOperations, + UserSessionsOperations, + WorkspacesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DesktopVirtualizationMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """DesktopVirtualizationMgmtClient. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.desktopvirtualization.aio.operations.Operations + :ivar workspaces: WorkspacesOperations operations + :vartype workspaces: azure.mgmt.desktopvirtualization.aio.operations.WorkspacesOperations + :ivar scaling_plans: ScalingPlansOperations operations + :vartype scaling_plans: azure.mgmt.desktopvirtualization.aio.operations.ScalingPlansOperations + :ivar scaling_plan_pooled_schedules: ScalingPlanPooledSchedulesOperations operations + :vartype scaling_plan_pooled_schedules: + azure.mgmt.desktopvirtualization.aio.operations.ScalingPlanPooledSchedulesOperations + :ivar application_groups: ApplicationGroupsOperations operations + :vartype application_groups: + azure.mgmt.desktopvirtualization.aio.operations.ApplicationGroupsOperations + :ivar start_menu_items: StartMenuItemsOperations operations + :vartype start_menu_items: + azure.mgmt.desktopvirtualization.aio.operations.StartMenuItemsOperations + :ivar applications: ApplicationsOperations operations + :vartype applications: azure.mgmt.desktopvirtualization.aio.operations.ApplicationsOperations + :ivar desktops: DesktopsOperations operations + :vartype desktops: azure.mgmt.desktopvirtualization.aio.operations.DesktopsOperations + :ivar host_pools: HostPoolsOperations operations + :vartype host_pools: azure.mgmt.desktopvirtualization.aio.operations.HostPoolsOperations + :ivar user_sessions: UserSessionsOperations operations + :vartype user_sessions: azure.mgmt.desktopvirtualization.aio.operations.UserSessionsOperations + :ivar session_hosts: SessionHostsOperations operations + :vartype session_hosts: azure.mgmt.desktopvirtualization.aio.operations.SessionHostsOperations + :ivar msix_packages: MSIXPackagesOperations operations + :vartype msix_packages: azure.mgmt.desktopvirtualization.aio.operations.MSIXPackagesOperations + :ivar msix_images: MsixImagesOperations operations + :vartype msix_images: azure.mgmt.desktopvirtualization.aio.operations.MsixImagesOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-09-09". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DesktopVirtualizationMgmtClientConfiguration( + 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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.scaling_plans = ScalingPlansOperations(self._client, self._config, self._serialize, self._deserialize) + self.scaling_plan_pooled_schedules = ScalingPlanPooledSchedulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_groups = ApplicationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.start_menu_items = StartMenuItemsOperations(self._client, self._config, self._serialize, self._deserialize) + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.desktops = DesktopsOperations(self._client, self._config, self._serialize, self._deserialize) + self.host_pools = HostPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_sessions = UserSessionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.session_hosts = SessionHostsOperations(self._client, self._config, self._serialize, self._deserialize) + self.msix_packages = MSIXPackagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.msix_images = MsixImagesOperations(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/dpcodegen/python/send_request + + :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) -> "DesktopVirtualizationMgmtClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_patch.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/__init__.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/__init__.py index 63576d0654da..432b50de74a4 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/__init__.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/__init__.py @@ -9,6 +9,7 @@ from ._operations import Operations from ._workspaces_operations import WorkspacesOperations from ._scaling_plans_operations import ScalingPlansOperations +from ._scaling_plan_pooled_schedules_operations import ScalingPlanPooledSchedulesOperations from ._application_groups_operations import ApplicationGroupsOperations from ._start_menu_items_operations import StartMenuItemsOperations from ._applications_operations import ApplicationsOperations @@ -18,22 +19,25 @@ from ._session_hosts_operations import SessionHostsOperations from ._msix_packages_operations import MSIXPackagesOperations from ._msix_images_operations import MsixImagesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Operations', - 'WorkspacesOperations', - 'ScalingPlansOperations', - 'ApplicationGroupsOperations', - 'StartMenuItemsOperations', - 'ApplicationsOperations', - 'DesktopsOperations', - 'HostPoolsOperations', - 'UserSessionsOperations', - 'SessionHostsOperations', - 'MSIXPackagesOperations', - 'MsixImagesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', + "Operations", + "WorkspacesOperations", + "ScalingPlansOperations", + "ScalingPlanPooledSchedulesOperations", + "ApplicationGroupsOperations", + "StartMenuItemsOperations", + "ApplicationsOperations", + "DesktopsOperations", + "HostPoolsOperations", + "UserSessionsOperations", + "SessionHostsOperations", + "MSIXPackagesOperations", + "MsixImagesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_application_groups_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_application_groups_operations.py index 46ebddcc524f..dcbe48063a08 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_application_groups_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_application_groups_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,152 +6,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._application_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApplicationGroupsOperations: - """ApplicationGroupsOperations 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. +class ApplicationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`application_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( - self, - resource_group_name: str, - application_group_name: str, - **kwargs: Any - ) -> "_models.ApplicationGroup": + self, resource_group_name: str, application_group_name: str, **kwargs: Any + ) -> _models.ApplicationGroup: """Get an application group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationGroup, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ApplicationGroup - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroup] + + request = build_get_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('ApplicationGroup', pipeline_response) + deserialized = self._deserialize("ApplicationGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}"} # type: ignore + + @overload async def create_or_update( self, resource_group_name: str, application_group_name: str, - application_group: "_models.ApplicationGroup", + application_group: _models.ApplicationGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ApplicationGroup": + ) -> _models.ApplicationGroup: """Create or update an applicationGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str - :param application_group: Object containing ApplicationGroup definitions. - :type application_group: ~desktop_virtualization_api_client.models.ApplicationGroup + :param application_group: Object containing ApplicationGroup definitions. Required. + :type application_group: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationGroup, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ApplicationGroup - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + application_group_name: str, + application_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationGroup: + """Create or update an applicationGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_group: Object containing ApplicationGroup definitions. Required. + :type application_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_group_name: str, + application_group: Union[_models.ApplicationGroup, IO], + **kwargs: Any + ) -> _models.ApplicationGroup: + """Create or update an applicationGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_group: Object containing ApplicationGroup definitions. Is either a model + type or a IO type. Required. + :type application_group: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(application_group, 'ApplicationGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application_group, (IO, bytes)): + _content = application_group + else: + _json = self._serialize.body(application_group, "ApplicationGroup") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -158,61 +261,66 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApplicationGroup', pipeline_response) + deserialized = self._deserialize("ApplicationGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApplicationGroup', pipeline_response) + deserialized = self._deserialize("ApplicationGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - application_group_name: str, - **kwargs: Any + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_group_name: str, **kwargs: Any ) -> None: """Remove an applicationGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -222,131 +330,238 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}"} # type: ignore + @overload async def update( self, resource_group_name: str, application_group_name: str, - application_group: Optional["_models.ApplicationGroupPatch"] = None, + application_group: Optional[_models.ApplicationGroupPatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ApplicationGroup": + ) -> _models.ApplicationGroup: """Update an applicationGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str - :param application_group: Object containing ApplicationGroup definitions. - :type application_group: ~desktop_virtualization_api_client.models.ApplicationGroupPatch + :param application_group: Object containing ApplicationGroup definitions. Default value is + None. + :type application_group: ~azure.mgmt.desktopvirtualization.models.ApplicationGroupPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationGroup, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ApplicationGroup - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + async def update( + self, + resource_group_name: str, + application_group_name: str, + application_group: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationGroup: + """Update an applicationGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_group: Object containing ApplicationGroup definitions. Default value is + None. + :type application_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ - # 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') + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_group_name: str, + application_group: Optional[Union[_models.ApplicationGroupPatch, IO]] = None, + **kwargs: Any + ) -> _models.ApplicationGroup: + """Update an applicationGroup. - body_content_kwargs = {} # type: Dict[str, Any] - if application_group is not None: - body_content = self._serialize.body(application_group, 'ApplicationGroupPatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_group: Object containing ApplicationGroup definitions. Is either a model + type or a IO type. Default value is None. + :type application_group: ~azure.mgmt.desktopvirtualization.models.ApplicationGroupPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application_group, (IO, bytes)): + _content = application_group else: - body_content = None - 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) + if application_group is not None: + _json = self._serialize.body(application_group, "ApplicationGroupPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApplicationGroup', pipeline_response) + deserialized = self._deserialize("ApplicationGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, filter: Optional[str] = None, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApplicationGroupList"]: + ) -> AsyncIterable["_models.ApplicationGroup"]: """List applicationGroups. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param filter: OData filter expression. Valid properties for filtering are - applicationGroupType. + applicationGroupType. Default value is None. :type filter: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.ApplicationGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ApplicationGroup or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ApplicationGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroupList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroupList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationGroupList', pipeline_response) + deserialized = self._deserialize("ApplicationGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -355,7 +570,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -364,61 +581,75 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups"} # type: ignore + + @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ApplicationGroupList"]: + self, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ApplicationGroup"]: """List applicationGroups in subscription. :param filter: OData filter expression. Valid properties for filtering are - applicationGroupType. + applicationGroupType. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.ApplicationGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ApplicationGroup or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ApplicationGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroupList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroupList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationGroupList', pipeline_response) + deserialized = self._deserialize("ApplicationGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -427,7 +658,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -436,7 +669,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/applicationGroups'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/applicationGroups"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_applications_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_applications_operations.py index e3ae135cc559..be978a82ae5f 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_applications_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_applications_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,160 +6,270 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._applications_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApplicationsOperations: - """ApplicationsOperations 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. +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( - self, - resource_group_name: str, - application_group_name: str, - application_name: str, - **kwargs: Any - ) -> "_models.Application": + self, resource_group_name: str, application_group_name: str, application_name: str, **kwargs: Any + ) -> _models.Application: """Get an application. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :param application_name: The name of the application within the specified application group. + Required. :type application_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Application - :raises: ~azure.core.exceptions.HttpResponseError + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + request = build_get_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}"} # type: ignore + + @overload async def create_or_update( self, resource_group_name: str, application_group_name: str, application_name: str, - application: "_models.Application", + application: _models.Application, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Application": + ) -> _models.Application: """Create or update an application. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :param application_name: The name of the application within the specified application group. + Required. :type application_name: str - :param application: Object containing Application definitions. - :type application: ~desktop_virtualization_api_client.models.Application + :param application: Object containing Application definitions. Required. + :type application: ~azure.mgmt.desktopvirtualization.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Application - :raises: ~azure.core.exceptions.HttpResponseError + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + application_group_name: str, + application_name: str, + application: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Create or update an application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_name: The name of the application within the specified application group. + Required. + :type application_name: str + :param application: Object containing Application definitions. Required. + :type application: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + application_group_name: str, + application_name: str, + application: Union[_models.Application, IO], + **kwargs: Any + ) -> _models.Application: + """Create or update an application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_name: The name of the application within the specified application group. + Required. + :type application_name: str + :param application: Object containing Application definitions. Is either a model type or a IO + type. Required. + :type application: ~azure.mgmt.desktopvirtualization.models.Application or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(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(application, 'Application') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application, (IO, bytes)): + _content = application + else: + _json = self._serialize.body(application, "Application") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -166,65 +277,70 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - application_group_name: str, - application_name: str, - **kwargs: Any + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_group_name: str, application_name: str, **kwargs: Any ) -> None: """Remove an application. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :param application_name: The name of the application within the specified application group. + Required. :type application_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=24, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -234,133 +350,248 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}"} # type: ignore + @overload async def update( self, resource_group_name: str, application_group_name: str, application_name: str, - application: Optional["_models.ApplicationPatch"] = None, + application: Optional[_models.ApplicationPatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Application": + ) -> _models.Application: """Update an application. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :param application_name: The name of the application within the specified application group. + Required. :type application_name: str - :param application: Object containing Application definitions. - :type application: ~desktop_virtualization_api_client.models.ApplicationPatch + :param application: Object containing Application definitions. Default value is None. + :type application: ~azure.mgmt.desktopvirtualization.models.ApplicationPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Application - :raises: ~azure.core.exceptions.HttpResponseError + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + async def update( + self, + resource_group_name: str, + application_group_name: str, + application_name: str, + application: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Update an application. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_name: The name of the application within the specified application group. + Required. + :type application_name: str + :param application: Object containing Application definitions. Default value is None. + :type application: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_group_name: str, + application_name: str, + application: Optional[Union[_models.ApplicationPatch, IO]] = None, + **kwargs: Any + ) -> _models.Application: + """Update an application. - body_content_kwargs = {} # type: Dict[str, Any] - if application is not None: - body_content = self._serialize.body(application, 'ApplicationPatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_name: The name of the application within the specified application group. + Required. + :type application_name: str + :param application: Object containing Application definitions. Is either a model type or a IO + type. Default value is None. + :type application: ~azure.mgmt.desktopvirtualization.models.ApplicationPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application, (IO, bytes)): + _content = application else: - body_content = None - 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) + if application is not None: + _json = self._serialize.body(application, "ApplicationPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}"} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, application_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApplicationList"]: + ) -> AsyncIterable["_models.Application"]: """List applications. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.ApplicationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationList', pipeline_response) + deserialized = self._deserialize("ApplicationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -369,7 +600,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,7 +611,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_desktops_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_desktops_operations.py index 8fe2d9073f00..abc306685058 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_desktops_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_desktops_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,229 +6,361 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._desktops_operations import build_get_request, build_list_request, build_update_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DesktopsOperations: - """DesktopsOperations 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. +class DesktopsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`desktops` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( - self, - resource_group_name: str, - application_group_name: str, - desktop_name: str, - **kwargs: Any - ) -> "_models.Desktop": + self, resource_group_name: str, application_group_name: str, desktop_name: str, **kwargs: Any + ) -> _models.Desktop: """Get a desktop. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str - :param desktop_name: The name of the desktop within the specified desktop group. + :param desktop_name: The name of the desktop within the specified desktop group. Required. :type desktop_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Desktop, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Desktop - :raises: ~azure.core.exceptions.HttpResponseError + :return: Desktop or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Desktop + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Desktop"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'desktopName': self._serialize.url("desktop_name", desktop_name, 'str', max_length=24, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Desktop] + + request = build_get_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + desktop_name=desktop_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('Desktop', pipeline_response) + deserialized = self._deserialize("Desktop", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}"} # type: ignore + + @overload async def update( self, resource_group_name: str, application_group_name: str, desktop_name: str, - desktop: Optional["_models.DesktopPatch"] = None, + desktop: Optional[_models.DesktopPatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Desktop": + ) -> _models.Desktop: """Update a desktop. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str - :param desktop_name: The name of the desktop within the specified desktop group. + :param desktop_name: The name of the desktop within the specified desktop group. Required. :type desktop_name: str - :param desktop: Object containing Desktop definitions. - :type desktop: ~desktop_virtualization_api_client.models.DesktopPatch + :param desktop: Object containing Desktop definitions. Default value is None. + :type desktop: ~azure.mgmt.desktopvirtualization.models.DesktopPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Desktop, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Desktop - :raises: ~azure.core.exceptions.HttpResponseError + :return: Desktop or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Desktop + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Desktop"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'desktopName': self._serialize.url("desktop_name", desktop_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + async def update( + self, + resource_group_name: str, + application_group_name: str, + desktop_name: str, + desktop: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Desktop: + """Update a desktop. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param desktop_name: The name of the desktop within the specified desktop group. Required. + :type desktop_name: str + :param desktop: Object containing Desktop definitions. Default value is None. + :type desktop: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Desktop or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Desktop + :raises ~azure.core.exceptions.HttpResponseError: + """ - body_content_kwargs = {} # type: Dict[str, Any] - if desktop is not None: - body_content = self._serialize.body(desktop, 'DesktopPatch') + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_group_name: str, + desktop_name: str, + desktop: Optional[Union[_models.DesktopPatch, IO]] = None, + **kwargs: Any + ) -> _models.Desktop: + """Update a desktop. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param desktop_name: The name of the desktop within the specified desktop group. Required. + :type desktop_name: str + :param desktop: Object containing Desktop definitions. Is either a model type or a IO type. + Default value is None. + :type desktop: ~azure.mgmt.desktopvirtualization.models.DesktopPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Desktop or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Desktop + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Desktop] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(desktop, (IO, bytes)): + _content = desktop else: - body_content = None - 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) + if desktop is not None: + _json = self._serialize.body(desktop, "DesktopPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + desktop_name=desktop_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Desktop', pipeline_response) + deserialized = self._deserialize("Desktop", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}"} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, application_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DesktopList"]: + ) -> AsyncIterable["_models.Desktop"]: """List desktops. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DesktopList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.DesktopList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Desktop or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.Desktop] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DesktopList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DesktopList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DesktopList', pipeline_response) + deserialized = self._deserialize("DesktopList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -236,7 +369,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,7 +380,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_host_pools_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_host_pools_operations.py index 1af3c03a2e92..073f44855bea 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_host_pools_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_host_pools_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,152 +6,249 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._host_pools_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_retrieve_registration_token_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class HostPoolsOperations: - """HostPoolsOperations 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. +class HostPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`host_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def get( - self, - resource_group_name: str, - host_pool_name: str, - **kwargs: Any - ) -> "_models.HostPool": + @distributed_trace_async + async def get(self, resource_group_name: str, host_pool_name: str, **kwargs: Any) -> _models.HostPool: """Get a host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HostPool, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.HostPool - :raises: ~azure.core.exceptions.HttpResponseError + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPool] + + request = build_get_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('HostPool', pipeline_response) + deserialized = self._deserialize("HostPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}"} # type: ignore + + @overload async def create_or_update( self, resource_group_name: str, host_pool_name: str, - host_pool: "_models.HostPool", + host_pool: _models.HostPool, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.HostPool": + ) -> _models.HostPool: + """Create or update a host pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param host_pool: Object containing HostPool definitions. Required. + :type host_pool: ~azure.mgmt.desktopvirtualization.models.HostPool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + host_pool_name: str, + host_pool: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HostPool: + """Create or update a host pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param host_pool: Object containing HostPool definitions. Required. + :type host_pool: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, host_pool_name: str, host_pool: Union[_models.HostPool, IO], **kwargs: Any + ) -> _models.HostPool: """Create or update a host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str - :param host_pool: Object containing HostPool definitions. - :type host_pool: ~desktop_virtualization_api_client.models.HostPool + :param host_pool: Object containing HostPool definitions. Is either a model type or a IO type. + Required. + :type host_pool: ~azure.mgmt.desktopvirtualization.models.HostPool or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HostPool, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.HostPool - :raises: ~azure.core.exceptions.HttpResponseError + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(host_pool, 'HostPool') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPool] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(host_pool, (IO, bytes)): + _content = host_pool + else: + _json = self._serialize.body(host_pool, "HostPool") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -158,66 +256,69 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('HostPool', pipeline_response) + deserialized = self._deserialize("HostPool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('HostPool', pipeline_response) + deserialized = self._deserialize("HostPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - host_pool_name: str, - force: Optional[bool] = None, - **kwargs: Any + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, host_pool_name: str, force: Optional[bool] = None, **kwargs: Any ) -> None: """Remove a host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str - :param force: Force flag to delete sessionHost. + :param force: Force flag to delete sessionHost. Default value is None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -227,125 +328,231 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}"} # type: ignore + @overload async def update( self, resource_group_name: str, host_pool_name: str, - host_pool: Optional["_models.HostPoolPatch"] = None, + host_pool: Optional[_models.HostPoolPatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.HostPool": + ) -> _models.HostPool: """Update a host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str - :param host_pool: Object containing HostPool definitions. - :type host_pool: ~desktop_virtualization_api_client.models.HostPoolPatch + :param host_pool: Object containing HostPool definitions. Default value is None. + :type host_pool: ~azure.mgmt.desktopvirtualization.models.HostPoolPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HostPool, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.HostPool - :raises: ~azure.core.exceptions.HttpResponseError + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPool"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + async def update( + self, + resource_group_name: str, + host_pool_name: str, + host_pool: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HostPool: + """Update a host pool. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param host_pool: Object containing HostPool definitions. Default value is None. + :type host_pool: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: + """ - body_content_kwargs = {} # type: Dict[str, Any] - if host_pool is not None: - body_content = self._serialize.body(host_pool, 'HostPoolPatch') + @distributed_trace_async + async def update( + self, + resource_group_name: str, + host_pool_name: str, + host_pool: Optional[Union[_models.HostPoolPatch, IO]] = None, + **kwargs: Any + ) -> _models.HostPool: + """Update a host pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param host_pool: Object containing HostPool definitions. Is either a model type or a IO type. + Default value is None. + :type host_pool: ~azure.mgmt.desktopvirtualization.models.HostPoolPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPool] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(host_pool, (IO, bytes)): + _content = host_pool else: - body_content = None - 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) + if host_pool is not None: + _json = self._serialize.body(host_pool, "HostPoolPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('HostPool', pipeline_response) + deserialized = self._deserialize("HostPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.HostPoolList"]: + ) -> AsyncIterable["_models.HostPool"]: """List hostPools. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HostPoolList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.HostPoolList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either HostPool or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.HostPool] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPoolList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPoolList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('HostPoolList', pipeline_response) + deserialized = self._deserialize("HostPoolList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -354,7 +561,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,55 +572,84 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools"} # type: ignore + @distributed_trace def list( self, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.HostPoolList"]: + ) -> AsyncIterable["_models.HostPool"]: """List hostPools in subscription. + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HostPoolList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.HostPoolList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either HostPool or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.HostPool] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPoolList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPoolList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('HostPoolList', pipeline_response) + deserialized = self._deserialize("HostPoolList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -420,7 +658,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -429,65 +669,69 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/hostPools'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/hostPools"} # type: ignore + @distributed_trace_async async def retrieve_registration_token( - self, - resource_group_name: str, - host_pool_name: str, - **kwargs: Any - ) -> "_models.RegistrationInfo": + self, resource_group_name: str, host_pool_name: str, **kwargs: Any + ) -> _models.RegistrationInfo: """Registration token of the host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistrationInfo, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.RegistrationInfo - :raises: ~azure.core.exceptions.HttpResponseError + :return: RegistrationInfo or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.RegistrationInfo + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.retrieve_registration_token.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistrationInfo] + + request = build_retrieve_registration_token_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.retrieve_registration_token.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('RegistrationInfo', pipeline_response) + deserialized = self._deserialize("RegistrationInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - retrieve_registration_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/retrieveRegistrationToken'} # type: ignore + + retrieve_registration_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/retrieveRegistrationToken"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_msix_images_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_msix_images_operations.py index ca996fc5e294..b5d5b3f684f3 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_msix_images_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_msix_images_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,204 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._msix_images_operations import build_expand_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MsixImagesOperations: - """MsixImagesOperations 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. +class MsixImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`msix_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def expand( + self, + resource_group_name: str, + host_pool_name: str, + msix_image_uri: _models.MSIXImageURI, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncIterable["_models.ExpandMsixImage"]: + """Expands and Lists MSIX packages in an Image, given the Image Path. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_image_uri: Object containing URI to MSIX Image. Required. + :type msix_image_uri: ~azure.mgmt.desktopvirtualization.models.MSIXImageURI + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExpandMsixImage or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ExpandMsixImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def expand( + self, + resource_group_name: str, + host_pool_name: str, + msix_image_uri: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncIterable["_models.ExpandMsixImage"]: + """Expands and Lists MSIX packages in an Image, given the Image Path. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_image_uri: Object containing URI to MSIX Image. Required. + :type msix_image_uri: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExpandMsixImage or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ExpandMsixImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace def expand( self, resource_group_name: str, host_pool_name: str, - msix_image_uri: "_models.MSIXImageURI", + msix_image_uri: Union[_models.MSIXImageURI, IO], **kwargs: Any - ) -> AsyncIterable["_models.ExpandMsixImageList"]: + ) -> AsyncIterable["_models.ExpandMsixImage"]: """Expands and Lists MSIX packages in an Image, given the Image Path. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str - :param msix_image_uri: Object containing URI to MSIX Image. - :type msix_image_uri: ~desktop_virtualization_api_client.models.MSIXImageURI + :param msix_image_uri: Object containing URI to MSIX Image. Is either a model type or a IO + type. Required. + :type msix_image_uri: ~azure.mgmt.desktopvirtualization.models.MSIXImageURI or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExpandMsixImageList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.ExpandMsixImageList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ExpandMsixImage or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ExpandMsixImage] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpandMsixImageList"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExpandMsixImageList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - content_type = "application/json" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(msix_image_uri, (IO, bytes)): + _content = msix_image_uri + else: + _json = self._serialize.body(msix_image_uri, "MSIXImageURI") def prepare_request(next_link=None): - # 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') - if not next_link: - # Construct URL - url = self.expand.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(msix_image_uri, 'MSIXImageURI') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + request = build_expand_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.expand.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(msix_image_uri, 'MSIXImageURI') - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ExpandMsixImageList', pipeline_response) + deserialized = self._deserialize("ExpandMsixImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,7 +212,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,7 +223,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - expand.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/expandMsixImage'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + expand.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/expandMsixImage"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_msix_packages_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_msix_packages_operations.py index cc3e816f638c..53b3f668e38c 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_msix_packages_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_msix_packages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,162 +6,270 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._msix_packages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MSIXPackagesOperations: - """MSIXPackagesOperations 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. +class MSIXPackagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`msix_packages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( - self, - resource_group_name: str, - host_pool_name: str, - msix_package_full_name: str, - **kwargs: Any - ) -> "_models.MSIXPackage": + self, resource_group_name: str, host_pool_name: str, msix_package_full_name: str, **kwargs: Any + ) -> _models.MSIXPackage: """Get a msixpackage. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param msix_package_full_name: The version specific package full name of the MSIX package - within specified hostpool. + within specified hostpool. Required. :type msix_package_full_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MSIXPackage, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.MSIXPackage - :raises: ~azure.core.exceptions.HttpResponseError + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MSIXPackage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'msixPackageFullName': self._serialize.url("msix_package_full_name", msix_package_full_name, 'str', max_length=100, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MSIXPackage] + + request = build_get_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + msix_package_full_name=msix_package_full_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('MSIXPackage', pipeline_response) + deserialized = self._deserialize("MSIXPackage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}"} # type: ignore + + @overload async def create_or_update( self, resource_group_name: str, host_pool_name: str, msix_package_full_name: str, - msix_package: "_models.MSIXPackage", + msix_package: _models.MSIXPackage, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.MSIXPackage": + ) -> _models.MSIXPackage: """Create or update a MSIX package. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param msix_package_full_name: The version specific package full name of the MSIX package - within specified hostpool. + within specified hostpool. Required. :type msix_package_full_name: str - :param msix_package: Object containing MSIX Package definitions. - :type msix_package: ~desktop_virtualization_api_client.models.MSIXPackage + :param msix_package: Object containing MSIX Package definitions. Required. + :type msix_package: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MSIXPackage, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.MSIXPackage - :raises: ~azure.core.exceptions.HttpResponseError + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MSIXPackage: + """Create or update a MSIX package. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_package_full_name: The version specific package full name of the MSIX package + within specified hostpool. Required. + :type msix_package_full_name: str + :param msix_package: Object containing MSIX Package definitions. Required. + :type msix_package: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: Union[_models.MSIXPackage, IO], + **kwargs: Any + ) -> _models.MSIXPackage: + """Create or update a MSIX package. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_package_full_name: The version specific package full name of the MSIX package + within specified hostpool. Required. + :type msix_package_full_name: str + :param msix_package: Object containing MSIX Package definitions. Is either a model type or a + IO type. Required. + :type msix_package: ~azure.mgmt.desktopvirtualization.models.MSIXPackage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MSIXPackage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'msixPackageFullName': self._serialize.url("msix_package_full_name", msix_package_full_name, 'str', max_length=100, min_length=3), - } - url = self._client.format_url(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(msix_package, 'MSIXPackage') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MSIXPackage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(msix_package, (IO, bytes)): + _content = msix_package + else: + _json = self._serialize.body(msix_package, "MSIXPackage") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + msix_package_full_name=msix_package_full_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -168,66 +277,70 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MSIXPackage', pipeline_response) + deserialized = self._deserialize("MSIXPackage", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('MSIXPackage', pipeline_response) + deserialized = self._deserialize("MSIXPackage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - host_pool_name: str, - msix_package_full_name: str, - **kwargs: Any + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, host_pool_name: str, msix_package_full_name: str, **kwargs: Any ) -> None: """Remove an MSIX Package. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param msix_package_full_name: The version specific package full name of the MSIX package - within specified hostpool. + within specified hostpool. Required. :type msix_package_full_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'msixPackageFullName': self._serialize.url("msix_package_full_name", msix_package_full_name, 'str', max_length=100, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + msix_package_full_name=msix_package_full_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -237,134 +350,248 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}"} # type: ignore + @overload async def update( self, resource_group_name: str, host_pool_name: str, msix_package_full_name: str, - msix_package: Optional["_models.MSIXPackagePatch"] = None, + msix_package: Optional[_models.MSIXPackagePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.MSIXPackage": + ) -> _models.MSIXPackage: """Update an MSIX Package. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param msix_package_full_name: The version specific package full name of the MSIX package - within specified hostpool. + within specified hostpool. Required. :type msix_package_full_name: str - :param msix_package: Object containing MSIX Package definitions. - :type msix_package: ~desktop_virtualization_api_client.models.MSIXPackagePatch + :param msix_package: Object containing MSIX Package definitions. Default value is None. + :type msix_package: ~azure.mgmt.desktopvirtualization.models.MSIXPackagePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MSIXPackage, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.MSIXPackage - :raises: ~azure.core.exceptions.HttpResponseError + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MSIXPackage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'msixPackageFullName': self._serialize.url("msix_package_full_name", msix_package_full_name, 'str', max_length=100, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + async def update( + self, + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MSIXPackage: + """Update an MSIX Package. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_package_full_name: The version specific package full name of the MSIX package + within specified hostpool. Required. + :type msix_package_full_name: str + :param msix_package: Object containing MSIX Package definitions. Default value is None. + :type msix_package: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: Optional[Union[_models.MSIXPackagePatch, IO]] = None, + **kwargs: Any + ) -> _models.MSIXPackage: + """Update an MSIX Package. - body_content_kwargs = {} # type: Dict[str, Any] - if msix_package is not None: - body_content = self._serialize.body(msix_package, 'MSIXPackagePatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_package_full_name: The version specific package full name of the MSIX package + within specified hostpool. Required. + :type msix_package_full_name: str + :param msix_package: Object containing MSIX Package definitions. Is either a model type or a IO + type. Default value is None. + :type msix_package: ~azure.mgmt.desktopvirtualization.models.MSIXPackagePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MSIXPackage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(msix_package, (IO, bytes)): + _content = msix_package else: - body_content = None - 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) + if msix_package is not None: + _json = self._serialize.body(msix_package, "MSIXPackagePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + msix_package_full_name=msix_package_full_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MSIXPackage', pipeline_response) + deserialized = self._deserialize("MSIXPackage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}"} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, host_pool_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.MSIXPackageList"]: + ) -> AsyncIterable["_models.MSIXPackage"]: """List MSIX packages in hostpool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MSIXPackageList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.MSIXPackageList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MSIXPackage or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.MSIXPackage] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MSIXPackageList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MSIXPackageList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MSIXPackageList', pipeline_response) + deserialized = self._deserialize("MSIXPackageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -373,7 +600,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -382,7 +611,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_operations.py index 09238b5f3413..e00e9a2762a8 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceProviderOperationList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all of the available operations the Desktop Virtualization resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceProviderOperation or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceProviderOperationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,7 +124,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,7 +135,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DesktopVirtualization/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DesktopVirtualization/operations"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_patch.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_private_endpoint_connections_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index b88375bb62b7..000000000000 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,578 +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 -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 PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - 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_host_pool( - self, - resource_group_name: str, - host_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResultWithSystemData"]: - """List private endpoint connections associated with hostpool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResultWithSystemData or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.PrivateEndpointConnectionListResultWithSystemData] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResultWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - 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('PrivateEndpointConnectionListResultWithSystemData', 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_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateEndpointConnections'} # type: ignore - - async def get_by_host_pool( - self, - resource_group_name: str, - host_pool_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnectionWithSystemData": - """Get a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionWithSystemData, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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('PrivateEndpointConnectionWithSystemData', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - async def delete_by_host_pool( - self, - resource_group_name: str, - host_pool_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> None: - """Remove a connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_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 = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - async def update_by_host_pool( - self, - resource_group_name: str, - host_pool_name: str, - private_endpoint_connection_name: str, - connection: "_models.PrivateEndpointConnection", - **kwargs: Any - ) -> "_models.PrivateEndpointConnectionWithSystemData": - """Approve or reject a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_name: str - :param connection: Object containing the updated connection. - :type connection: ~desktop_virtualization_api_client.models.PrivateEndpointConnection - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionWithSystemData, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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(connection, 'PrivateEndpointConnection') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('PrivateEndpointConnectionWithSystemData', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResultWithSystemData"]: - """List private endpoint connections. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResultWithSystemData or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.PrivateEndpointConnectionListResultWithSystemData] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResultWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - 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('PrivateEndpointConnectionListResultWithSystemData', 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_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateEndpointConnections'} # type: ignore - - async def get_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnectionWithSystemData": - """Get a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionWithSystemData, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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('PrivateEndpointConnectionWithSystemData', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - async def delete_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> None: - """Remove a connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_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 = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - async def update_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - connection: "_models.PrivateEndpointConnection", - **kwargs: Any - ) -> "_models.PrivateEndpointConnectionWithSystemData": - """Approve or reject a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_name: str - :param connection: Object containing the updated connection. - :type connection: ~desktop_virtualization_api_client.models.PrivateEndpointConnection - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionWithSystemData, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_by_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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(connection, 'PrivateEndpointConnection') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('PrivateEndpointConnectionWithSystemData', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_private_link_resources_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index da58a5f3d051..000000000000 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,190 +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 -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 PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - 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_host_pool( - self, - resource_group_name: str, - host_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: - """List the private link resources available for this hostpool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - 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('PrivateLinkResourceListResult', 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_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateLinkResources'} # type: ignore - - def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: - """List the private link resources available for this workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - 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('PrivateLinkResourceListResult', 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_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateLinkResources'} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_scaling_plan_pooled_schedules_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_scaling_plan_pooled_schedules_operations.py new file mode 100644 index 000000000000..863f08a32208 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_scaling_plan_pooled_schedules_operations.py @@ -0,0 +1,616 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._scaling_plan_pooled_schedules_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ScalingPlanPooledSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`scaling_plan_pooled_schedules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, scaling_plan_name: str, scaling_plan_schedule_name: str, **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Get a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanPooledSchedule] + + request = build_get_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + scaling_plan_schedule_name=scaling_plan_schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScalingPlanPooledSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}"} # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: _models.ScalingPlanPooledSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Create or update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. + Required. + :type scaling_plan_schedule: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Create or update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. + Required. + :type scaling_plan_schedule: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: Union[_models.ScalingPlanPooledSchedule, IO], + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Create or update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. Is + either a model type or a IO type. Required. + :type scaling_plan_schedule: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanPooledSchedule] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scaling_plan_schedule, (IO, bytes)): + _content = scaling_plan_schedule + else: + _json = self._serialize.body(scaling_plan_schedule, "ScalingPlanPooledSchedule") + + request = build_create_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + scaling_plan_schedule_name=scaling_plan_schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ScalingPlanPooledSchedule", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ScalingPlanPooledSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, scaling_plan_name: str, scaling_plan_schedule_name: str, **kwargs: Any + ) -> None: + """Remove a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + scaling_plan_schedule_name=scaling_plan_schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 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.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: Optional[_models.ScalingPlanPooledSchedulePatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. Default + value is None. + :type scaling_plan_schedule: + ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedulePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. Default + value is None. + :type scaling_plan_schedule: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: Optional[Union[_models.ScalingPlanPooledSchedulePatch, IO]] = None, + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. Is + either a model type or a IO type. Default value is None. + :type scaling_plan_schedule: + ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedulePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanPooledSchedule] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scaling_plan_schedule, (IO, bytes)): + _content = scaling_plan_schedule + else: + if scaling_plan_schedule is not None: + _json = self._serialize.body(scaling_plan_schedule, "ScalingPlanPooledSchedulePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + scaling_plan_schedule_name=scaling_plan_schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScalingPlanPooledSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + scaling_plan_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ScalingPlanPooledSchedule"]: + """List ScalingPlanPooledSchedules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScalingPlanPooledSchedule or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanPooledScheduleList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ScalingPlanPooledScheduleList", 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( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_scaling_plans_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_scaling_plans_operations.py index 2efe4941d547..7f6fb35725db 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_scaling_plans_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_scaling_plans_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,152 +6,253 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._scaling_plans_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_host_pool_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScalingPlansOperations: - """ScalingPlansOperations 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. +class ScalingPlansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`scaling_plans` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def get( - self, - resource_group_name: str, - scaling_plan_name: str, - **kwargs: Any - ) -> "_models.ScalingPlan": + @distributed_trace_async + async def get(self, resource_group_name: str, scaling_plan_name: str, **kwargs: Any) -> _models.ScalingPlan: """Get a scaling plan. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scaling_plan_name: The name of the scaling plan. + :param scaling_plan_name: The name of the scaling plan. Required. :type scaling_plan_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScalingPlan, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ScalingPlan - :raises: ~azure.core.exceptions.HttpResponseError + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlan"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'scalingPlanName': self._serialize.url("scaling_plan_name", scaling_plan_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlan] + + request = build_get_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('ScalingPlan', pipeline_response) + deserialized = self._deserialize("ScalingPlan", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}"} # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: _models.ScalingPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlan: + """Create or update a scaling plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan: Object containing scaling plan definitions. Required. + :type scaling_plan: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload async def create( self, resource_group_name: str, scaling_plan_name: str, - scaling_plan: "_models.ScalingPlan", + scaling_plan: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ScalingPlan": + ) -> _models.ScalingPlan: """Create or update a scaling plan. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scaling_plan_name: The name of the scaling plan. + :param scaling_plan_name: The name of the scaling plan. Required. :type scaling_plan_name: str - :param scaling_plan: Object containing scaling plan definitions. - :type scaling_plan: ~desktop_virtualization_api_client.models.ScalingPlan + :param scaling_plan: Object containing scaling plan definitions. Required. + :type scaling_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScalingPlan, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ScalingPlan - :raises: ~azure.core.exceptions.HttpResponseError + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: Union[_models.ScalingPlan, IO], + **kwargs: Any + ) -> _models.ScalingPlan: + """Create or update a scaling plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan: Object containing scaling plan definitions. Is either a model type or a IO + type. Required. + :type scaling_plan: ~azure.mgmt.desktopvirtualization.models.ScalingPlan or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlan"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'scalingPlanName': self._serialize.url("scaling_plan_name", scaling_plan_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(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(scaling_plan, 'ScalingPlan') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlan] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scaling_plan, (IO, bytes)): + _content = scaling_plan + else: + _json = self._serialize.body(scaling_plan, "ScalingPlan") + + request = build_create_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -158,61 +260,66 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScalingPlan', pipeline_response) + deserialized = self._deserialize("ScalingPlan", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScalingPlan', pipeline_response) + deserialized = self._deserialize("ScalingPlan", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - scaling_plan_name: str, - **kwargs: Any + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, scaling_plan_name: str, **kwargs: Any ) -> None: """Remove a scaling plan. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scaling_plan_name: The name of the scaling plan. + :param scaling_plan_name: The name of the scaling plan. Required. :type scaling_plan_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'scalingPlanName': self._serialize.url("scaling_plan_name", scaling_plan_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -222,125 +329,231 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}"} # type: ignore + @overload async def update( self, resource_group_name: str, scaling_plan_name: str, - scaling_plan: Optional["_models.ScalingPlanPatch"] = None, + scaling_plan: Optional[_models.ScalingPlanPatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ScalingPlan": + ) -> _models.ScalingPlan: """Update a scaling plan. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scaling_plan_name: The name of the scaling plan. + :param scaling_plan_name: The name of the scaling plan. Required. :type scaling_plan_name: str - :param scaling_plan: Object containing scaling plan definitions. - :type scaling_plan: ~desktop_virtualization_api_client.models.ScalingPlanPatch + :param scaling_plan: Object containing scaling plan definitions. Default value is None. + :type scaling_plan: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScalingPlan, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ScalingPlan - :raises: ~azure.core.exceptions.HttpResponseError + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlan"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'scalingPlanName': self._serialize.url("scaling_plan_name", scaling_plan_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + async def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlan: + """Update a scaling plan. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan: Object containing scaling plan definitions. Default value is None. + :type scaling_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ - body_content_kwargs = {} # type: Dict[str, Any] - if scaling_plan is not None: - body_content = self._serialize.body(scaling_plan, 'ScalingPlanPatch') + @distributed_trace_async + async def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: Optional[Union[_models.ScalingPlanPatch, IO]] = None, + **kwargs: Any + ) -> _models.ScalingPlan: + """Update a scaling plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan: Object containing scaling plan definitions. Is either a model type or a IO + type. Default value is None. + :type scaling_plan: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlan] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scaling_plan, (IO, bytes)): + _content = scaling_plan else: - body_content = None - 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) + if scaling_plan is not None: + _json = self._serialize.body(scaling_plan, "ScalingPlanPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScalingPlan', pipeline_response) + deserialized = self._deserialize("ScalingPlan", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ScalingPlanList"]: + ) -> AsyncIterable["_models.ScalingPlan"]: """List scaling plans. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScalingPlanList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.ScalingPlanList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScalingPlan or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ScalingPlan] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlanList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ScalingPlanList', pipeline_response) + deserialized = self._deserialize("ScalingPlanList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,7 +562,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,55 +573,84 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans"} # type: ignore + @distributed_trace def list_by_subscription( self, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ScalingPlanList"]: + ) -> AsyncIterable["_models.ScalingPlan"]: """List scaling plans in subscription. + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScalingPlanList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.ScalingPlanList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScalingPlan or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ScalingPlan] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlanList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ScalingPlanList', pipeline_response) + deserialized = self._deserialize("ScalingPlanList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -415,7 +659,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -424,63 +670,93 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/scalingPlans'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/scalingPlans"} # type: ignore + @distributed_trace def list_by_host_pool( self, resource_group_name: str, host_pool_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ScalingPlanList"]: + ) -> AsyncIterable["_models.ScalingPlan"]: """List scaling plan associated with hostpool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScalingPlanList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.ScalingPlanList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScalingPlan or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.ScalingPlan] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlanList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_host_pool_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_host_pool.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ScalingPlanList', pipeline_response) + deserialized = self._deserialize("ScalingPlanList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -489,7 +765,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -498,7 +776,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/scalingPlans'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_host_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/scalingPlans"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_session_hosts_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_session_hosts_operations.py index ad2bccd104f7..b4a1afef84ba 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_session_hosts_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_session_hosts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._session_hosts_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SessionHostsOperations: - """SessionHostsOperations 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. +class SessionHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`session_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( - self, - resource_group_name: str, - host_pool_name: str, - session_host_name: str, - **kwargs: Any - ) -> "_models.SessionHost": + self, resource_group_name: str, host_pool_name: str, session_host_name: str, **kwargs: Any + ) -> _models.SessionHost: """Get a session host. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SessionHost, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.SessionHost - :raises: ~azure.core.exceptions.HttpResponseError + :return: SessionHost or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.SessionHost + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SessionHost"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SessionHost] + + request = build_get_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('SessionHost', pipeline_response) + deserialized = self._deserialize("SessionHost", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}'} # type: ignore - async def delete( + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, host_pool_name: str, @@ -114,48 +142,55 @@ async def delete( """Remove a SessionHost. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str - :param force: Force flag to force sessionHost deletion even when userSession exists. + :param force: Force flag to force sessionHost deletion even when userSession exists. Default + value is None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -165,138 +200,261 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + force: Optional[bool] = None, + session_host: Optional[_models.SessionHostPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SessionHost: + """Update a session host. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param session_host_name: The name of the session host within the specified host pool. + Required. + :type session_host_name: str + :param force: Force flag to update assign, unassign or reassign personal desktop. Default value + is None. + :type force: bool + :param session_host: Object containing SessionHost definitions. Default value is None. + :type session_host: ~azure.mgmt.desktopvirtualization.models.SessionHostPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SessionHost or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.SessionHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + force: Optional[bool] = None, + session_host: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SessionHost: + """Update a session host. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param session_host_name: The name of the session host within the specified host pool. + Required. + :type session_host_name: str + :param force: Force flag to update assign, unassign or reassign personal desktop. Default value + is None. + :type force: bool + :param session_host: Object containing SessionHost definitions. Default value is None. + :type session_host: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SessionHost or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.SessionHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async async def update( self, resource_group_name: str, host_pool_name: str, session_host_name: str, force: Optional[bool] = None, - session_host: Optional["_models.SessionHostPatch"] = None, + session_host: Optional[Union[_models.SessionHostPatch, IO]] = None, **kwargs: Any - ) -> "_models.SessionHost": + ) -> _models.SessionHost: """Update a session host. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str - :param force: Force flag to update assign, unassign or reassign personal desktop. + :param force: Force flag to update assign, unassign or reassign personal desktop. Default value + is None. :type force: bool - :param session_host: Object containing SessionHost definitions. - :type session_host: ~desktop_virtualization_api_client.models.SessionHostPatch + :param session_host: Object containing SessionHost definitions. Is either a model type or a IO + type. Default value is None. + :type session_host: ~azure.mgmt.desktopvirtualization.models.SessionHostPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SessionHost, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.SessionHost - :raises: ~azure.core.exceptions.HttpResponseError + :return: SessionHost or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.SessionHost + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SessionHost"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - - # 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] - if session_host is not None: - body_content = self._serialize.body(session_host, 'SessionHostPatch') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SessionHost] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(session_host, (IO, bytes)): + _content = session_host else: - body_content = None - 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) + if session_host is not None: + _json = self._serialize.body(session_host, "SessionHostPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SessionHost', pipeline_response) + deserialized = self._deserialize("SessionHost", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}"} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, host_pool_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SessionHostList"]: + ) -> AsyncIterable["_models.SessionHost"]: """List sessionHosts. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SessionHostList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.SessionHostList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SessionHost or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.SessionHost] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SessionHostList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SessionHostList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SessionHostList', pipeline_response) + deserialized = self._deserialize("SessionHostList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -305,7 +463,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -314,7 +474,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_start_menu_items_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_start_menu_items_operations.py index 2307bae8b8c2..fa5ac9cf757c 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_start_menu_items_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_start_menu_items_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._start_menu_items_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StartMenuItemsOperations: - """StartMenuItemsOperations 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. +class StartMenuItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`start_menu_items` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, resource_group_name: str, application_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.StartMenuItemList"]: + ) -> AsyncIterable["_models.StartMenuItem"]: """List start menu items in the given application group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StartMenuItemList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.StartMenuItemList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StartMenuItem or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.StartMenuItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StartMenuItemList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StartMenuItemList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StartMenuItemList', pipeline_response) + deserialized = self._deserialize("StartMenuItemList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,7 +148,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +159,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/startMenuItems'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/startMenuItems"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_user_sessions_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_user_sessions_operations.py index c8ede54eb807..2122ee4ceaaa 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_user_sessions_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_user_sessions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +6,153 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._user_sessions_operations import ( + build_delete_request, + build_disconnect_request, + build_get_request, + build_list_by_host_pool_request, + build_list_request, + build_send_message_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UserSessionsOperations: - """UserSessionsOperations 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. +class UserSessionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`user_sessions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_host_pool( self, resource_group_name: str, host_pool_name: str, filter: Optional[str] = None, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.UserSessionList"]: + ) -> AsyncIterable["_models.UserSession"]: """List userSessions. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param filter: OData filter expression. Valid properties for filtering are userprincipalname - and sessionstate. + and sessionstate. Default value is None. :type filter: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserSessionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.UserSessionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either UserSession or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.UserSession] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSessionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSessionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_host_pool_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + filter=filter, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_host_pool.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserSessionList', pipeline_response) + deserialized = self._deserialize("UserSessionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,7 +161,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -116,78 +172,83 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/userSessions'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_host_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/userSessions"} # type: ignore + @distributed_trace_async async def get( - self, - resource_group_name: str, - host_pool_name: str, - session_host_name: str, - user_session_id: str, - **kwargs: Any - ) -> "_models.UserSession": + self, resource_group_name: str, host_pool_name: str, session_host_name: str, user_session_id: str, **kwargs: Any + ) -> _models.UserSession: """Get a userSession. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :param user_session_id: The name of the user session within the specified session host. + Required. :type user_session_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSession, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.UserSession - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserSession or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.UserSession + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSession"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - 'userSessionId': self._serialize.url("user_session_id", user_session_id, 'str', max_length=24, min_length=1), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSession] + + request = build_get_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + user_session_id=user_session_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('UserSession', pipeline_response) + deserialized = self._deserialize("UserSession", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}'} # type: ignore - async def delete( + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, host_pool_name: str, @@ -199,51 +260,58 @@ async def delete( """Remove a userSession. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :param user_session_id: The name of the user session within the specified session host. + Required. :type user_session_id: str - :param force: Force flag to login off userSession. + :param force: Force flag to login off userSession. Default value is None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - 'userSessionId': self._serialize.url("user_session_id", user_session_id, 'str', max_length=24, min_length=1), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + user_session_id=user_session_id, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -253,64 +321,96 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}"} # type: ignore + @distributed_trace def list( self, resource_group_name: str, host_pool_name: str, session_host_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.UserSessionList"]: + ) -> AsyncIterable["_models.UserSession"]: """List userSessions. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserSessionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.UserSessionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either UserSession or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.UserSession] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSessionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSessionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserSessionList', pipeline_response) + deserialized = self._deserialize("UserSessionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -319,7 +419,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -328,63 +430,66 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def disconnect( - self, - resource_group_name: str, - host_pool_name: str, - session_host_name: str, - user_session_id: str, - **kwargs: Any + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions"} # type: ignore + + @distributed_trace_async + async def disconnect( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, host_pool_name: str, session_host_name: str, user_session_id: str, **kwargs: Any ) -> None: """Disconnect a userSession. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :param user_session_id: The name of the user session within the specified session host. + Required. :type user_session_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.disconnect.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - 'userSessionId': self._serialize.url("user_session_id", user_session_id, 'str', max_length=24, min_length=1), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_disconnect_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + user_session_id=user_session_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.disconnect.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -394,71 +499,165 @@ async def disconnect( if cls: return cls(pipeline_response, None, {}) - disconnect.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/disconnect'} # type: ignore + disconnect.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/disconnect"} # type: ignore - async def send_message( + @overload + async def send_message( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, host_pool_name: str, session_host_name: str, user_session_id: str, - send_message: Optional["_models.SendMessage"] = None, + send_message: Optional[_models.SendMessage] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Send a message to a user. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :param user_session_id: The name of the user session within the specified session host. + Required. :type user_session_id: str - :param send_message: Object containing message includes title and message body. - :type send_message: ~desktop_virtualization_api_client.models.SendMessage + :param send_message: Object containing message includes title and message body. Default value + is None. + :type send_message: ~azure.mgmt.desktopvirtualization.models.SendMessage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.send_message.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - 'userSessionId': self._serialize.url("user_session_id", user_session_id, 'str', max_length=24, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + async def send_message( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + send_message: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Send a message to a user. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param session_host_name: The name of the session host within the specified host pool. + Required. + :type session_host_name: str + :param user_session_id: The name of the user session within the specified session host. + Required. + :type user_session_id: str + :param send_message: Object containing message includes title and message body. Default value + is None. + :type send_message: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ - body_content_kwargs = {} # type: Dict[str, Any] - if send_message is not None: - body_content = self._serialize.body(send_message, 'SendMessage') + @distributed_trace_async + async def send_message( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + send_message: Optional[Union[_models.SendMessage, IO]] = None, + **kwargs: Any + ) -> None: + """Send a message to a user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param session_host_name: The name of the session host within the specified host pool. + Required. + :type session_host_name: str + :param user_session_id: The name of the user session within the specified session host. + Required. + :type user_session_id: str + :param send_message: Object containing message includes title and message body. Is either a + model type or a IO type. Default value is None. + :type send_message: ~azure.mgmt.desktopvirtualization.models.SendMessage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(send_message, (IO, bytes)): + _content = send_message else: - body_content = None - 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) + if send_message is not None: + _json = self._serialize.body(send_message, "SendMessage") + else: + _json = None + + request = build_send_message_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + user_session_id=user_session_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.send_message.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -468,4 +667,4 @@ async def send_message( if cls: return cls(pipeline_response, None, {}) - send_message.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/sendMessage'} # type: ignore + send_message.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/sendMessage"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_workspaces_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_workspaces_operations.py index 5898aa71c78f..9f30855c4999 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_workspaces_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/aio/operations/_workspaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,152 +6,248 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._workspaces_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspacesOperations: - """WorkspacesOperations 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. +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.aio.DesktopVirtualizationMgmtClient`'s + :attr:`workspaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.Workspace": + @distributed_trace_async + async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: """Get a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Workspace, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Workspace - :raises: ~azure.core.exceptions.HttpResponseError + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + + request = build_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + workspace: _models.Workspace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Create or update a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param workspace: Object containing Workspace definitions. Required. + :type workspace: ~azure.mgmt.desktopvirtualization.models.Workspace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload async def create_or_update( self, resource_group_name: str, workspace_name: str, - workspace: "_models.Workspace", + workspace: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Workspace": + ) -> _models.Workspace: """Create or update a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace: Object containing Workspace definitions. - :type workspace: ~desktop_virtualization_api_client.models.Workspace + :param workspace: Object containing Workspace definitions. Required. + :type workspace: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Workspace, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Workspace - :raises: ~azure.core.exceptions.HttpResponseError + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, workspace_name: str, workspace: Union[_models.Workspace, IO], **kwargs: Any + ) -> _models.Workspace: + """Create or update a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param workspace: Object containing Workspace definitions. Is either a model type or a IO type. + Required. + :type workspace: ~azure.mgmt.desktopvirtualization.models.Workspace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(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(workspace, 'Workspace') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace, (IO, bytes)): + _content = workspace + else: + _json = self._serialize.body(workspace, "Workspace") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -158,61 +255,66 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, workspace_name: str, **kwargs: Any ) -> None: """Remove a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -222,125 +324,231 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}"} # type: ignore + @overload async def update( self, resource_group_name: str, workspace_name: str, - workspace: Optional["_models.WorkspacePatch"] = None, + workspace: Optional[_models.WorkspacePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Workspace": + ) -> _models.Workspace: """Update a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace: Object containing Workspace definitions. - :type workspace: ~desktop_virtualization_api_client.models.WorkspacePatch + :param workspace: Object containing Workspace definitions. Default value is None. + :type workspace: ~azure.mgmt.desktopvirtualization.models.WorkspacePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Workspace, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Workspace - :raises: ~azure.core.exceptions.HttpResponseError + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + async def update( + self, + resource_group_name: str, + workspace_name: str, + workspace: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Update a workspace. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param workspace: Object containing Workspace definitions. Default value is None. + :type workspace: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + workspace_name: str, + workspace: Optional[Union[_models.WorkspacePatch, IO]] = None, + **kwargs: Any + ) -> _models.Workspace: + """Update a workspace. - body_content_kwargs = {} # type: Dict[str, Any] - if workspace is not None: - body_content = self._serialize.body(workspace, 'WorkspacePatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param workspace: Object containing Workspace definitions. Is either a model type or a IO type. + Default value is None. + :type workspace: ~azure.mgmt.desktopvirtualization.models.WorkspacePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace, (IO, bytes)): + _content = workspace else: - body_content = None - 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) + if workspace is not None: + _json = self._serialize.body(workspace, "WorkspacePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceList"]: + ) -> AsyncIterable["_models.Workspace"]: """List workspaces. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.WorkspaceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Workspace or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkspaceList', pipeline_response) + deserialized = self._deserialize("WorkspaceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,7 +557,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,55 +568,69 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceList"]: + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Workspace"]: """List workspaces in subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~desktop_virtualization_api_client.models.WorkspaceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Workspace or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.desktopvirtualization.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkspaceList', pipeline_response) + deserialized = self._deserialize("WorkspaceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -415,7 +639,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -424,7 +650,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/workspaces'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/workspaces"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/__init__.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/__init__.py index cf41bbdc9aa6..c6aed3196266 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/__init__.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/__init__.py @@ -6,256 +6,186 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Application - from ._models_py3 import ApplicationGroup - from ._models_py3 import ApplicationGroupList - from ._models_py3 import ApplicationGroupPatch - from ._models_py3 import ApplicationList - from ._models_py3 import ApplicationPatch - from ._models_py3 import CloudErrorProperties - from ._models_py3 import Desktop - from ._models_py3 import DesktopList - from ._models_py3 import DesktopPatch - from ._models_py3 import ExpandMsixImage - from ._models_py3 import ExpandMsixImageList - from ._models_py3 import HostPool - from ._models_py3 import HostPoolList - from ._models_py3 import HostPoolPatch - from ._models_py3 import Identity - from ._models_py3 import LogSpecification - from ._models_py3 import MSIXImageURI - from ._models_py3 import MSIXPackage - from ._models_py3 import MSIXPackageList - from ._models_py3 import MSIXPackagePatch - from ._models_py3 import MigrationRequestProperties - from ._models_py3 import MsixPackageApplications - from ._models_py3 import MsixPackageDependencies - from ._models_py3 import OperationProperties - from ._models_py3 import Plan - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResultWithSystemData - from ._models_py3 import PrivateEndpointConnectionWithSystemData - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourceListResult - from ._models_py3 import PrivateLinkServiceConnectionState - from ._models_py3 import RegistrationInfo - from ._models_py3 import RegistrationInfoPatch - from ._models_py3 import Resource - from ._models_py3 import ResourceModelWithAllowedPropertySet - from ._models_py3 import ResourceModelWithAllowedPropertySetIdentity - from ._models_py3 import ResourceModelWithAllowedPropertySetPlan - from ._models_py3 import ResourceModelWithAllowedPropertySetSku - from ._models_py3 import ResourceProviderOperation - from ._models_py3 import ResourceProviderOperationDisplay - from ._models_py3 import ResourceProviderOperationList - from ._models_py3 import ScalingHostPoolReference - from ._models_py3 import ScalingPlan - from ._models_py3 import ScalingPlanList - from ._models_py3 import ScalingPlanPatch - from ._models_py3 import ScalingSchedule - from ._models_py3 import SendMessage - from ._models_py3 import ServiceSpecification - from ._models_py3 import SessionHost - from ._models_py3 import SessionHostHealthCheckFailureDetails - from ._models_py3 import SessionHostHealthCheckReport - from ._models_py3 import SessionHostList - from ._models_py3 import SessionHostPatch - from ._models_py3 import Sku - from ._models_py3 import StartMenuItem - from ._models_py3 import StartMenuItemList - from ._models_py3 import SystemData - from ._models_py3 import Time - from ._models_py3 import UserSession - from ._models_py3 import UserSessionList - from ._models_py3 import Workspace - from ._models_py3 import WorkspaceList - from ._models_py3 import WorkspacePatch -except (SyntaxError, ImportError): - from ._models import Application # type: ignore - from ._models import ApplicationGroup # type: ignore - from ._models import ApplicationGroupList # type: ignore - from ._models import ApplicationGroupPatch # type: ignore - from ._models import ApplicationList # type: ignore - from ._models import ApplicationPatch # type: ignore - from ._models import CloudErrorProperties # type: ignore - from ._models import Desktop # type: ignore - from ._models import DesktopList # type: ignore - from ._models import DesktopPatch # type: ignore - from ._models import ExpandMsixImage # type: ignore - from ._models import ExpandMsixImageList # type: ignore - from ._models import HostPool # type: ignore - from ._models import HostPoolList # type: ignore - from ._models import HostPoolPatch # type: ignore - from ._models import Identity # type: ignore - from ._models import LogSpecification # type: ignore - from ._models import MSIXImageURI # type: ignore - from ._models import MSIXPackage # type: ignore - from ._models import MSIXPackageList # type: ignore - from ._models import MSIXPackagePatch # type: ignore - from ._models import MigrationRequestProperties # type: ignore - from ._models import MsixPackageApplications # type: ignore - from ._models import MsixPackageDependencies # type: ignore - from ._models import OperationProperties # type: ignore - from ._models import Plan # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResultWithSystemData # type: ignore - from ._models import PrivateEndpointConnectionWithSystemData # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourceListResult # type: ignore - from ._models import PrivateLinkServiceConnectionState # type: ignore - from ._models import RegistrationInfo # type: ignore - from ._models import RegistrationInfoPatch # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceModelWithAllowedPropertySet # type: ignore - from ._models import ResourceModelWithAllowedPropertySetIdentity # type: ignore - from ._models import ResourceModelWithAllowedPropertySetPlan # type: ignore - from ._models import ResourceModelWithAllowedPropertySetSku # type: ignore - from ._models import ResourceProviderOperation # type: ignore - from ._models import ResourceProviderOperationDisplay # type: ignore - from ._models import ResourceProviderOperationList # type: ignore - from ._models import ScalingHostPoolReference # type: ignore - from ._models import ScalingPlan # type: ignore - from ._models import ScalingPlanList # type: ignore - from ._models import ScalingPlanPatch # type: ignore - from ._models import ScalingSchedule # type: ignore - from ._models import SendMessage # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import SessionHost # type: ignore - from ._models import SessionHostHealthCheckFailureDetails # type: ignore - from ._models import SessionHostHealthCheckReport # type: ignore - from ._models import SessionHostList # type: ignore - from ._models import SessionHostPatch # type: ignore - from ._models import Sku # type: ignore - from ._models import StartMenuItem # type: ignore - from ._models import StartMenuItemList # type: ignore - from ._models import SystemData # type: ignore - from ._models import Time # type: ignore - from ._models import UserSession # type: ignore - from ._models import UserSessionList # type: ignore - from ._models import Workspace # type: ignore - from ._models import WorkspaceList # type: ignore - from ._models import WorkspacePatch # type: ignore +from ._models_py3 import AgentUpdatePatchProperties +from ._models_py3 import AgentUpdateProperties +from ._models_py3 import Application +from ._models_py3 import ApplicationGroup +from ._models_py3 import ApplicationGroupList +from ._models_py3 import ApplicationGroupPatch +from ._models_py3 import ApplicationList +from ._models_py3 import ApplicationPatch +from ._models_py3 import CloudErrorProperties +from ._models_py3 import Desktop +from ._models_py3 import DesktopList +from ._models_py3 import DesktopPatch +from ._models_py3 import ExpandMsixImage +from ._models_py3 import ExpandMsixImageList +from ._models_py3 import HostPool +from ._models_py3 import HostPoolList +from ._models_py3 import HostPoolPatch +from ._models_py3 import Identity +from ._models_py3 import LogSpecification +from ._models_py3 import MSIXImageURI +from ._models_py3 import MSIXPackage +from ._models_py3 import MSIXPackageList +from ._models_py3 import MSIXPackagePatch +from ._models_py3 import MaintenanceWindowPatchProperties +from ._models_py3 import MaintenanceWindowProperties +from ._models_py3 import MsixPackageApplications +from ._models_py3 import MsixPackageDependencies +from ._models_py3 import OperationProperties +from ._models_py3 import Plan +from ._models_py3 import RegistrationInfo +from ._models_py3 import RegistrationInfoPatch +from ._models_py3 import Resource +from ._models_py3 import ResourceModelWithAllowedPropertySet +from ._models_py3 import ResourceModelWithAllowedPropertySetIdentity +from ._models_py3 import ResourceModelWithAllowedPropertySetPlan +from ._models_py3 import ResourceModelWithAllowedPropertySetSku +from ._models_py3 import ResourceProviderOperation +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList +from ._models_py3 import ScalingHostPoolReference +from ._models_py3 import ScalingPlan +from ._models_py3 import ScalingPlanList +from ._models_py3 import ScalingPlanPatch +from ._models_py3 import ScalingPlanPooledSchedule +from ._models_py3 import ScalingPlanPooledScheduleList +from ._models_py3 import ScalingPlanPooledSchedulePatch +from ._models_py3 import ScalingSchedule +from ._models_py3 import SendMessage +from ._models_py3 import ServiceSpecification +from ._models_py3 import SessionHost +from ._models_py3 import SessionHostHealthCheckFailureDetails +from ._models_py3 import SessionHostHealthCheckReport +from ._models_py3 import SessionHostList +from ._models_py3 import SessionHostPatch +from ._models_py3 import Sku +from ._models_py3 import StartMenuItem +from ._models_py3 import StartMenuItemList +from ._models_py3 import SystemData +from ._models_py3 import Time +from ._models_py3 import UserSession +from ._models_py3 import UserSessionList +from ._models_py3 import Workspace +from ._models_py3 import WorkspaceList +from ._models_py3 import WorkspacePatch -from ._desktop_virtualization_api_client_enums import ( - ApplicationGroupType, - ApplicationType, - CommandLineSetting, - CreatedByType, - HealthCheckName, - HealthCheckResult, - HostPoolType, - LoadBalancerType, - Operation, - PersonalDesktopAssignmentType, - PreferredAppGroupType, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - PublicNetworkAccess, - RegistrationTokenOperation, - RemoteApplicationType, - SSOSecretType, - ScalingHostPoolType, - ScalingScheduleDaysOfWeekItem, - SessionHostLoadBalancingAlgorithm, - SessionState, - SkuTier, - Status, - StopHostsWhen, - UpdateState, -) +from ._desktop_virtualization_mgmt_client_enums import ApplicationGroupType +from ._desktop_virtualization_mgmt_client_enums import ApplicationType +from ._desktop_virtualization_mgmt_client_enums import CommandLineSetting +from ._desktop_virtualization_mgmt_client_enums import CreatedByType +from ._desktop_virtualization_mgmt_client_enums import DayOfWeek +from ._desktop_virtualization_mgmt_client_enums import HealthCheckName +from ._desktop_virtualization_mgmt_client_enums import HealthCheckResult +from ._desktop_virtualization_mgmt_client_enums import HostPoolType +from ._desktop_virtualization_mgmt_client_enums import LoadBalancerType +from ._desktop_virtualization_mgmt_client_enums import PersonalDesktopAssignmentType +from ._desktop_virtualization_mgmt_client_enums import PreferredAppGroupType +from ._desktop_virtualization_mgmt_client_enums import RegistrationTokenOperation +from ._desktop_virtualization_mgmt_client_enums import RemoteApplicationType +from ._desktop_virtualization_mgmt_client_enums import SSOSecretType +from ._desktop_virtualization_mgmt_client_enums import ScalingHostPoolType +from ._desktop_virtualization_mgmt_client_enums import ScalingScheduleDaysOfWeekItem +from ._desktop_virtualization_mgmt_client_enums import SessionHostComponentUpdateType +from ._desktop_virtualization_mgmt_client_enums import SessionHostLoadBalancingAlgorithm +from ._desktop_virtualization_mgmt_client_enums import SessionState +from ._desktop_virtualization_mgmt_client_enums import SkuTier +from ._desktop_virtualization_mgmt_client_enums import Status +from ._desktop_virtualization_mgmt_client_enums import StopHostsWhen +from ._desktop_virtualization_mgmt_client_enums import UpdateState +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Application', - 'ApplicationGroup', - 'ApplicationGroupList', - 'ApplicationGroupPatch', - 'ApplicationList', - 'ApplicationPatch', - 'CloudErrorProperties', - 'Desktop', - 'DesktopList', - 'DesktopPatch', - 'ExpandMsixImage', - 'ExpandMsixImageList', - 'HostPool', - 'HostPoolList', - 'HostPoolPatch', - 'Identity', - 'LogSpecification', - 'MSIXImageURI', - 'MSIXPackage', - 'MSIXPackageList', - 'MSIXPackagePatch', - 'MigrationRequestProperties', - 'MsixPackageApplications', - 'MsixPackageDependencies', - 'OperationProperties', - 'Plan', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResultWithSystemData', - 'PrivateEndpointConnectionWithSystemData', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'RegistrationInfo', - 'RegistrationInfoPatch', - 'Resource', - 'ResourceModelWithAllowedPropertySet', - 'ResourceModelWithAllowedPropertySetIdentity', - 'ResourceModelWithAllowedPropertySetPlan', - 'ResourceModelWithAllowedPropertySetSku', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'ScalingHostPoolReference', - 'ScalingPlan', - 'ScalingPlanList', - 'ScalingPlanPatch', - 'ScalingSchedule', - 'SendMessage', - 'ServiceSpecification', - 'SessionHost', - 'SessionHostHealthCheckFailureDetails', - 'SessionHostHealthCheckReport', - 'SessionHostList', - 'SessionHostPatch', - 'Sku', - 'StartMenuItem', - 'StartMenuItemList', - 'SystemData', - 'Time', - 'UserSession', - 'UserSessionList', - 'Workspace', - 'WorkspaceList', - 'WorkspacePatch', - 'ApplicationGroupType', - 'ApplicationType', - 'CommandLineSetting', - 'CreatedByType', - 'HealthCheckName', - 'HealthCheckResult', - 'HostPoolType', - 'LoadBalancerType', - 'Operation', - 'PersonalDesktopAssignmentType', - 'PreferredAppGroupType', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'PublicNetworkAccess', - 'RegistrationTokenOperation', - 'RemoteApplicationType', - 'SSOSecretType', - 'ScalingHostPoolType', - 'ScalingScheduleDaysOfWeekItem', - 'SessionHostLoadBalancingAlgorithm', - 'SessionState', - 'SkuTier', - 'Status', - 'StopHostsWhen', - 'UpdateState', + "AgentUpdatePatchProperties", + "AgentUpdateProperties", + "Application", + "ApplicationGroup", + "ApplicationGroupList", + "ApplicationGroupPatch", + "ApplicationList", + "ApplicationPatch", + "CloudErrorProperties", + "Desktop", + "DesktopList", + "DesktopPatch", + "ExpandMsixImage", + "ExpandMsixImageList", + "HostPool", + "HostPoolList", + "HostPoolPatch", + "Identity", + "LogSpecification", + "MSIXImageURI", + "MSIXPackage", + "MSIXPackageList", + "MSIXPackagePatch", + "MaintenanceWindowPatchProperties", + "MaintenanceWindowProperties", + "MsixPackageApplications", + "MsixPackageDependencies", + "OperationProperties", + "Plan", + "RegistrationInfo", + "RegistrationInfoPatch", + "Resource", + "ResourceModelWithAllowedPropertySet", + "ResourceModelWithAllowedPropertySetIdentity", + "ResourceModelWithAllowedPropertySetPlan", + "ResourceModelWithAllowedPropertySetSku", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "ScalingHostPoolReference", + "ScalingPlan", + "ScalingPlanList", + "ScalingPlanPatch", + "ScalingPlanPooledSchedule", + "ScalingPlanPooledScheduleList", + "ScalingPlanPooledSchedulePatch", + "ScalingSchedule", + "SendMessage", + "ServiceSpecification", + "SessionHost", + "SessionHostHealthCheckFailureDetails", + "SessionHostHealthCheckReport", + "SessionHostList", + "SessionHostPatch", + "Sku", + "StartMenuItem", + "StartMenuItemList", + "SystemData", + "Time", + "UserSession", + "UserSessionList", + "Workspace", + "WorkspaceList", + "WorkspacePatch", + "ApplicationGroupType", + "ApplicationType", + "CommandLineSetting", + "CreatedByType", + "DayOfWeek", + "HealthCheckName", + "HealthCheckResult", + "HostPoolType", + "LoadBalancerType", + "PersonalDesktopAssignmentType", + "PreferredAppGroupType", + "RegistrationTokenOperation", + "RemoteApplicationType", + "SSOSecretType", + "ScalingHostPoolType", + "ScalingScheduleDaysOfWeekItem", + "SessionHostComponentUpdateType", + "SessionHostLoadBalancingAlgorithm", + "SessionState", + "SkuTier", + "Status", + "StopHostsWhen", + "UpdateState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_desktop_virtualization_api_client_enums.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_desktop_virtualization_mgmt_client_enums.py similarity index 68% rename from sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_desktop_virtualization_api_client_enums.py rename to sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_desktop_virtualization_mgmt_client_enums.py index 493339676783..3e542e166232 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_desktop_virtualization_api_client_enums.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_desktop_virtualization_mgmt_client_enums.py @@ -6,41 +6,25 @@ # 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 ApplicationGroupType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Resource Type of ApplicationGroup. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ApplicationGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Resource Type of ApplicationGroup.""" REMOTE_APP = "RemoteApp" DESKTOP = "Desktop" -class ApplicationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Application type of application. - """ + +class ApplicationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Application type of application.""" REMOTE_APP = "RemoteApp" DESKTOP = "Desktop" -class CommandLineSetting(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class CommandLineSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether this published application can be launched with command line arguments provided by the client, command line arguments specified at publish time, or no command line arguments at all. @@ -50,18 +34,30 @@ class CommandLineSetting(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ALLOW = "Allow" REQUIRE = "Require" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class HealthCheckName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Represents the name of the health check operation performed. - """ + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Day of the week.""" + + MONDAY = "Monday" + TUESDAY = "Tuesday" + WEDNESDAY = "Wednesday" + THURSDAY = "Thursday" + FRIDAY = "Friday" + SATURDAY = "Saturday" + SUNDAY = "Sunday" + + +class HealthCheckName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Represents the name of the health check operation performed.""" #: Verifies the SessionHost is joined to a domain. If this check fails is classified as fatal as #: no connection can succeed if the SessionHost is not joined to the domain. @@ -115,9 +111,9 @@ class HealthCheckName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: end-users. APP_ATTACH_HEALTH_CHECK = "AppAttachHealthCheck" -class HealthCheckResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Represents the Health state of the health check we performed. - """ + +class HealthCheckResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Represents the Health state of the health check we performed.""" #: Health check result is not currently known. UNKNOWN = "Unknown" @@ -128,9 +124,9 @@ class HealthCheckResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: We received a Shutdown notification. SESSION_HOST_SHUTDOWN = "SessionHostShutdown" -class HostPoolType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """HostPool type for desktop. - """ + +class HostPoolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """HostPool type for desktop.""" #: Users will be assigned a SessionHost either by administrators (PersonalDesktopAssignmentType = #: Direct) or upon connecting to the pool (PersonalDesktopAssignmentType = Automatic). They will @@ -142,92 +138,54 @@ class HostPoolType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: PersonalDesktopAssignmentType must be Direct. BYO_DESKTOP = "BYODesktop" -class LoadBalancerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the load balancer. - """ + +class LoadBalancerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the load balancer.""" BREADTH_FIRST = "BreadthFirst" DEPTH_FIRST = "DepthFirst" PERSISTENT = "Persistent" -class Operation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of operation for migration. - """ - #: Start the migration. - START = "Start" - #: Revoke the migration. - REVOKE = "Revoke" - #: Complete the migration. - COMPLETE = "Complete" - #: Hide the hostpool. - HIDE = "Hide" - #: Unhide the hostpool. - UNHIDE = "Unhide" - -class PersonalDesktopAssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """PersonalDesktopAssignment type for HostPool. - """ +class PersonalDesktopAssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PersonalDesktopAssignment type for HostPool.""" AUTOMATIC = "Automatic" DIRECT = "Direct" -class PreferredAppGroupType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of preferred application group type, default to Desktop Application Group - """ + +class PreferredAppGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of preferred application group type, default to Desktop Application Group.""" NONE = "None" DESKTOP = "Desktop" RAIL_APPLICATIONS = "RailApplications" -class PrivateEndpointConnectionProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current provisioning state. - """ - SUCCEEDED = "Succeeded" - CREATING = "Creating" - DELETING = "Deleting" - FAILED = "Failed" - -class PrivateEndpointServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The private endpoint connection status. - """ - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - -class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Enabled allows this resource to be accessed from both public and private networks, Disabled - allows this resource to only be accessed via private endpoints - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - -class RegistrationTokenOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of resetting the token. - """ +class RegistrationTokenOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of resetting the token.""" DELETE = "Delete" NONE = "None" UPDATE = "Update" -class RemoteApplicationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Resource Type of Application. - """ + +class RemoteApplicationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Resource Type of Application.""" IN_BUILT = "InBuilt" MSIX_APPLICATION = "MsixApplication" -class ScalingHostPoolType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """HostPool type for desktop. - """ + +class ScalingHostPoolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """HostPool type for desktop.""" #: Users get a new (random) SessionHost every time it connects to the HostPool. POOLED = "Pooled" -class ScalingScheduleDaysOfWeekItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class ScalingScheduleDaysOfWeekItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ScalingScheduleDaysOfWeekItem.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -237,16 +195,25 @@ class ScalingScheduleDaysOfWeekItem(with_metaclass(_CaseInsensitiveEnumMeta, str FRIDAY = "Friday" SATURDAY = "Saturday" -class SessionHostLoadBalancingAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Load balancing algorithm for ramp up period. - """ + +class SessionHostComponentUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of maintenance for session host components.""" + + #: Agent and other agent side components are delivery schedule is controlled by WVD Infra. + DEFAULT = "Default" + #: TenantAdmin have opted in for Scheduled Component Update feature. + SCHEDULED = "Scheduled" + + +class SessionHostLoadBalancingAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Load balancing algorithm for ramp up period.""" BREADTH_FIRST = "BreadthFirst" DEPTH_FIRST = "DepthFirst" -class SessionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """State of user session. - """ + +class SessionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of user session.""" UNKNOWN = "Unknown" ACTIVE = "Active" @@ -255,7 +222,8 @@ class SessionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LOG_OFF = "LogOff" USER_PROFILE_DISK_MOUNTED = "UserProfileDiskMounted" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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. """ @@ -265,18 +233,18 @@ class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class SSOSecretType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of single sign on Secret Type. - """ + +class SSOSecretType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of single sign on Secret Type.""" SHARED_KEY = "SharedKey" CERTIFICATE = "Certificate" SHARED_KEY_IN_KEY_VAULT = "SharedKeyInKeyVault" CERTIFICATE_IN_KEY_VAULT = "CertificateInKeyVault" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status for a SessionHost. - """ + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status for a SessionHost.""" #: Session Host has passed all the health checks and is available to handle connections. AVAILABLE = "Available" @@ -299,7 +267,7 @@ class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NO_HEARTBEAT = "NoHeartbeat" #: SessionHost is not joined to domain. NOT_JOINED_TO_DOMAIN = "NotJoinedToDomain" - #: SessionHost's domain trust relationship lost. + #: SessionHost's domain trust relationship lost DOMAIN_TRUST_RELATIONSHIP_LOST = "DomainTrustRelationshipLost" #: SxS stack installed on the SessionHost is not ready to receive connections. SX_S_STACK_LISTENER_NOT_READY = "SxSStackListenerNotReady" @@ -309,16 +277,16 @@ class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: connections might not fail, as these issues are not fatal. NEEDS_ASSISTANCE = "NeedsAssistance" -class StopHostsWhen(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Specifies when to stop hosts during ramp down period. - """ + +class StopHostsWhen(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies when to stop hosts during ramp down period.""" ZERO_SESSIONS = "ZeroSessions" ZERO_ACTIVE_SESSIONS = "ZeroActiveSessions" -class UpdateState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Update state of a SessionHost. - """ + +class UpdateState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Update state of a SessionHost.""" INITIAL = "Initial" PENDING = "Pending" diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_models.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_models.py deleted file mode 100644 index ddf752c9348e..000000000000 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_models.py +++ /dev/null @@ -1,3114 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Application(Resource): - """Schema for Application properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :ivar object_id: ObjectId of Application. (internal use). - :vartype object_id: str - :param description: Description of Application. - :type description: str - :param friendly_name: Friendly name of Application. - :type friendly_name: str - :param file_path: Specifies a path for the executable file for the application. - :type file_path: str - :param msix_package_family_name: Specifies the package family name for MSIX applications. - :type msix_package_family_name: str - :param msix_package_application_id: Specifies the package application Id for MSIX applications. - :type msix_package_application_id: str - :param application_type: Resource Type of Application. Possible values include: "InBuilt", - "MsixApplication". - :type application_type: str or ~desktop_virtualization_api_client.models.RemoteApplicationType - :param command_line_setting: Required. Specifies whether this published application can be - launched with command line arguments provided by the client, command line arguments specified - at publish time, or no command line arguments at all. Possible values include: "DoNotAllow", - "Allow", "Require". - :type command_line_setting: str or ~desktop_virtualization_api_client.models.CommandLineSetting - :param command_line_arguments: Command Line Arguments for Application. - :type command_line_arguments: str - :param show_in_portal: Specifies whether to show the RemoteApp program in the RD Web Access - server. - :type show_in_portal: bool - :param icon_path: Path to icon. - :type icon_path: str - :param icon_index: Index of the icon. - :type icon_index: int - :ivar icon_hash: Hash of the icon. - :vartype icon_hash: str - :ivar icon_content: the icon a 64 bit string as a byte array. - :vartype icon_content: bytearray - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'command_line_setting': {'required': True}, - 'icon_hash': {'readonly': True}, - 'icon_content': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'file_path': {'key': 'properties.filePath', 'type': 'str'}, - 'msix_package_family_name': {'key': 'properties.msixPackageFamilyName', 'type': 'str'}, - 'msix_package_application_id': {'key': 'properties.msixPackageApplicationId', 'type': 'str'}, - 'application_type': {'key': 'properties.applicationType', 'type': 'str'}, - 'command_line_setting': {'key': 'properties.commandLineSetting', 'type': 'str'}, - 'command_line_arguments': {'key': 'properties.commandLineArguments', 'type': 'str'}, - 'show_in_portal': {'key': 'properties.showInPortal', 'type': 'bool'}, - 'icon_path': {'key': 'properties.iconPath', 'type': 'str'}, - 'icon_index': {'key': 'properties.iconIndex', 'type': 'int'}, - 'icon_hash': {'key': 'properties.iconHash', 'type': 'str'}, - 'icon_content': {'key': 'properties.iconContent', 'type': 'bytearray'}, - } - - def __init__( - self, - **kwargs - ): - super(Application, self).__init__(**kwargs) - self.system_data = None - self.object_id = None - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.file_path = kwargs.get('file_path', None) - self.msix_package_family_name = kwargs.get('msix_package_family_name', None) - self.msix_package_application_id = kwargs.get('msix_package_application_id', None) - self.application_type = kwargs.get('application_type', None) - self.command_line_setting = kwargs['command_line_setting'] - self.command_line_arguments = kwargs.get('command_line_arguments', None) - self.show_in_portal = kwargs.get('show_in_portal', None) - self.icon_path = kwargs.get('icon_path', None) - self.icon_index = kwargs.get('icon_index', None) - self.icon_hash = None - self.icon_content = None - - -class ResourceModelWithAllowedPropertySet(msrest.serialization.Model): - """The resource model definition containing the full set of allowed properties for a resource. Except properties bag, there cannot be a top level property outside of this set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. - Indicates if this resource is managed by another Azure resource. If this is present, complete - mode deployment will not delete the resource if it is removed from the template since it is - managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceModelWithAllowedPropertySet, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - self.managed_by = kwargs.get('managed_by', None) - self.kind = kwargs.get('kind', None) - self.etag = None - self.tags = kwargs.get('tags', None) - self.identity = kwargs.get('identity', None) - self.sku = kwargs.get('sku', None) - self.plan = kwargs.get('plan', None) - - -class ApplicationGroup(ResourceModelWithAllowedPropertySet): - """Represents a ApplicationGroup definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. - Indicates if this resource is managed by another Azure resource. If this is present, complete - mode deployment will not delete the resource if it is removed from the template since it is - managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :ivar object_id: ObjectId of ApplicationGroup. (internal use). - :vartype object_id: str - :param description: Description of ApplicationGroup. - :type description: str - :param friendly_name: Friendly name of ApplicationGroup. - :type friendly_name: str - :param host_pool_arm_path: Required. HostPool arm path of ApplicationGroup. - :type host_pool_arm_path: str - :ivar workspace_arm_path: Workspace arm path of ApplicationGroup. - :vartype workspace_arm_path: str - :param application_group_type: Required. Resource Type of ApplicationGroup. Possible values - include: "RemoteApp", "Desktop". - :type application_group_type: str or - ~desktop_virtualization_api_client.models.ApplicationGroupType - :param migration_request: The registration info of HostPool. - :type migration_request: ~desktop_virtualization_api_client.models.MigrationRequestProperties - :ivar cloud_pc_resource: Is cloud pc resource. - :vartype cloud_pc_resource: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'host_pool_arm_path': {'required': True}, - 'workspace_arm_path': {'readonly': True}, - 'application_group_type': {'required': True}, - 'cloud_pc_resource': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'host_pool_arm_path': {'key': 'properties.hostPoolArmPath', 'type': 'str'}, - 'workspace_arm_path': {'key': 'properties.workspaceArmPath', 'type': 'str'}, - 'application_group_type': {'key': 'properties.applicationGroupType', 'type': 'str'}, - 'migration_request': {'key': 'properties.migrationRequest', 'type': 'MigrationRequestProperties'}, - 'cloud_pc_resource': {'key': 'properties.cloudPcResource', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationGroup, self).__init__(**kwargs) - self.system_data = None - self.object_id = None - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.host_pool_arm_path = kwargs['host_pool_arm_path'] - self.workspace_arm_path = None - self.application_group_type = kwargs['application_group_type'] - self.migration_request = kwargs.get('migration_request', None) - self.cloud_pc_resource = None - - -class ApplicationGroupList(msrest.serialization.Model): - """List of ApplicationGroup definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of ApplicationGroup definitions. - :type value: list[~desktop_virtualization_api_client.models.ApplicationGroup] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplicationGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationGroupList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ApplicationGroupPatch(Resource): - """ApplicationGroup properties that can be patched. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of ApplicationGroup. - :type description: str - :param friendly_name: Friendly name of ApplicationGroup. - :type friendly_name: 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'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationGroupPatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - - -class ApplicationList(msrest.serialization.Model): - """List of Application definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Application definitions. - :type value: list[~desktop_virtualization_api_client.models.Application] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Application]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ApplicationPatch(msrest.serialization.Model): - """Application properties that can be patched. - - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of Application. - :type description: str - :param friendly_name: Friendly name of Application. - :type friendly_name: str - :param file_path: Specifies a path for the executable file for the application. - :type file_path: str - :param command_line_setting: Specifies whether this published application can be launched with - command line arguments provided by the client, command line arguments specified at publish - time, or no command line arguments at all. Possible values include: "DoNotAllow", "Allow", - "Require". - :type command_line_setting: str or ~desktop_virtualization_api_client.models.CommandLineSetting - :param command_line_arguments: Command Line Arguments for Application. - :type command_line_arguments: str - :param show_in_portal: Specifies whether to show the RemoteApp program in the RD Web Access - server. - :type show_in_portal: bool - :param icon_path: Path to icon. - :type icon_path: str - :param icon_index: Index of the icon. - :type icon_index: int - :param msix_package_family_name: Specifies the package family name for MSIX applications. - :type msix_package_family_name: str - :param msix_package_application_id: Specifies the package application Id for MSIX applications. - :type msix_package_application_id: str - :param application_type: Resource Type of Application. Possible values include: "InBuilt", - "MsixApplication". - :type application_type: str or ~desktop_virtualization_api_client.models.RemoteApplicationType - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'file_path': {'key': 'properties.filePath', 'type': 'str'}, - 'command_line_setting': {'key': 'properties.commandLineSetting', 'type': 'str'}, - 'command_line_arguments': {'key': 'properties.commandLineArguments', 'type': 'str'}, - 'show_in_portal': {'key': 'properties.showInPortal', 'type': 'bool'}, - 'icon_path': {'key': 'properties.iconPath', 'type': 'str'}, - 'icon_index': {'key': 'properties.iconIndex', 'type': 'int'}, - 'msix_package_family_name': {'key': 'properties.msixPackageFamilyName', 'type': 'str'}, - 'msix_package_application_id': {'key': 'properties.msixPackageApplicationId', 'type': 'str'}, - 'application_type': {'key': 'properties.applicationType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationPatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.file_path = kwargs.get('file_path', None) - self.command_line_setting = kwargs.get('command_line_setting', None) - self.command_line_arguments = kwargs.get('command_line_arguments', None) - self.show_in_portal = kwargs.get('show_in_portal', None) - self.icon_path = kwargs.get('icon_path', None) - self.icon_index = kwargs.get('icon_index', None) - self.msix_package_family_name = kwargs.get('msix_package_family_name', None) - self.msix_package_application_id = kwargs.get('msix_package_application_id', None) - self.application_type = kwargs.get('application_type', None) - - -class CloudErrorProperties(msrest.serialization.Model): - """Cloud error object properties. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorProperties, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class Desktop(Resource): - """Schema for Desktop properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :ivar object_id: ObjectId of Desktop. (internal use). - :vartype object_id: str - :param description: Description of Desktop. - :type description: str - :param friendly_name: Friendly name of Desktop. - :type friendly_name: str - :ivar icon_hash: Hash of the icon. - :vartype icon_hash: str - :ivar icon_content: The icon a 64 bit string as a byte array. - :vartype icon_content: bytearray - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'icon_hash': {'readonly': True}, - 'icon_content': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'icon_hash': {'key': 'properties.iconHash', 'type': 'str'}, - 'icon_content': {'key': 'properties.iconContent', 'type': 'bytearray'}, - } - - def __init__( - self, - **kwargs - ): - super(Desktop, self).__init__(**kwargs) - self.system_data = None - self.object_id = None - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.icon_hash = None - self.icon_content = None - - -class DesktopList(msrest.serialization.Model): - """List of Desktop definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Desktop definitions. - :type value: list[~desktop_virtualization_api_client.models.Desktop] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Desktop]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DesktopList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class DesktopPatch(msrest.serialization.Model): - """Desktop properties that can be patched. - - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of Desktop. - :type description: str - :param friendly_name: Friendly name of Desktop. - :type friendly_name: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DesktopPatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - - -class ExpandMsixImage(Resource): - """Represents the definition of contents retrieved after expanding the MSIX Image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param package_alias: Alias of MSIX Package. - :type package_alias: str - :param image_path: VHD/CIM image path on Network Share. - :type image_path: str - :param package_name: Package Name from appxmanifest.xml. - :type package_name: str - :param package_family_name: Package Family Name from appxmanifest.xml. Contains Package Name - and Publisher name. - :type package_family_name: str - :param package_full_name: Package Full Name from appxmanifest.xml. - :type package_full_name: str - :param display_name: User friendly Name to be displayed in the portal. - :type display_name: str - :param package_relative_path: Relative Path to the package inside the image. - :type package_relative_path: str - :param is_regular_registration: Specifies how to register Package in feed. - :type is_regular_registration: bool - :param is_active: Make this version of the package the active one across the hostpool. - :type is_active: bool - :param package_dependencies: List of package dependencies. - :type package_dependencies: - list[~desktop_virtualization_api_client.models.MsixPackageDependencies] - :param version: Package Version found in the appxmanifest.xml. - :type version: str - :param last_updated: Date Package was last updated, found in the appxmanifest.xml. - :type last_updated: ~datetime.datetime - :param package_applications: List of package applications. - :type package_applications: - list[~desktop_virtualization_api_client.models.MsixPackageApplications] - """ - - _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'}, - 'package_alias': {'key': 'properties.packageAlias', 'type': 'str'}, - 'image_path': {'key': 'properties.imagePath', 'type': 'str'}, - 'package_name': {'key': 'properties.packageName', 'type': 'str'}, - 'package_family_name': {'key': 'properties.packageFamilyName', 'type': 'str'}, - 'package_full_name': {'key': 'properties.packageFullName', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'package_relative_path': {'key': 'properties.packageRelativePath', 'type': 'str'}, - 'is_regular_registration': {'key': 'properties.isRegularRegistration', 'type': 'bool'}, - 'is_active': {'key': 'properties.isActive', 'type': 'bool'}, - 'package_dependencies': {'key': 'properties.packageDependencies', 'type': '[MsixPackageDependencies]'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'last_updated': {'key': 'properties.lastUpdated', 'type': 'iso-8601'}, - 'package_applications': {'key': 'properties.packageApplications', 'type': '[MsixPackageApplications]'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpandMsixImage, self).__init__(**kwargs) - self.package_alias = kwargs.get('package_alias', None) - self.image_path = kwargs.get('image_path', None) - self.package_name = kwargs.get('package_name', None) - self.package_family_name = kwargs.get('package_family_name', None) - self.package_full_name = kwargs.get('package_full_name', None) - self.display_name = kwargs.get('display_name', None) - self.package_relative_path = kwargs.get('package_relative_path', None) - self.is_regular_registration = kwargs.get('is_regular_registration', None) - self.is_active = kwargs.get('is_active', None) - self.package_dependencies = kwargs.get('package_dependencies', None) - self.version = kwargs.get('version', None) - self.last_updated = kwargs.get('last_updated', None) - self.package_applications = kwargs.get('package_applications', None) - - -class ExpandMsixImageList(msrest.serialization.Model): - """List of MSIX package properties retrieved from MSIX Image expansion. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of MSIX package properties from give MSIX Image. - :type value: list[~desktop_virtualization_api_client.models.ExpandMsixImage] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ExpandMsixImage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpandMsixImageList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class HostPool(ResourceModelWithAllowedPropertySet): - """Represents a HostPool definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. - Indicates if this resource is managed by another Azure resource. If this is present, complete - mode deployment will not delete the resource if it is removed from the template since it is - managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :ivar object_id: ObjectId of HostPool. (internal use). - :vartype object_id: str - :param friendly_name: Friendly name of HostPool. - :type friendly_name: str - :param description: Description of HostPool. - :type description: str - :param host_pool_type: Required. HostPool type for desktop. Possible values include: - "Personal", "Pooled", "BYODesktop". - :type host_pool_type: str or ~desktop_virtualization_api_client.models.HostPoolType - :param personal_desktop_assignment_type: PersonalDesktopAssignment type for HostPool. Possible - values include: "Automatic", "Direct". - :type personal_desktop_assignment_type: str or - ~desktop_virtualization_api_client.models.PersonalDesktopAssignmentType - :param custom_rdp_property: Custom rdp property of HostPool. - :type custom_rdp_property: str - :param max_session_limit: The max session limit of HostPool. - :type max_session_limit: int - :param load_balancer_type: Required. The type of the load balancer. Possible values include: - "BreadthFirst", "DepthFirst", "Persistent". - :type load_balancer_type: str or ~desktop_virtualization_api_client.models.LoadBalancerType - :param ring: The ring number of HostPool. - :type ring: int - :param validation_environment: Is validation environment. - :type validation_environment: bool - :param registration_info: The registration info of HostPool. - :type registration_info: ~desktop_virtualization_api_client.models.RegistrationInfo - :param vm_template: VM template for sessionhosts configuration within hostpool. - :type vm_template: str - :ivar application_group_references: List of applicationGroup links. - :vartype application_group_references: list[str] - :param ssoadfs_authority: URL to customer ADFS server for signing WVD SSO certificates. - :type ssoadfs_authority: str - :param sso_client_id: ClientId for the registered Relying Party used to issue WVD SSO - certificates. - :type sso_client_id: str - :param sso_client_secret_key_vault_path: Path to Azure KeyVault storing the secret used for - communication to ADFS. - :type sso_client_secret_key_vault_path: str - :param sso_secret_type: The type of single sign on Secret Type. Possible values include: - "SharedKey", "Certificate", "SharedKeyInKeyVault", "CertificateInKeyVault". - :type sso_secret_type: str or ~desktop_virtualization_api_client.models.SSOSecretType - :param preferred_app_group_type: Required. The type of preferred application group type, - default to Desktop Application Group. Possible values include: "None", "Desktop", - "RailApplications". - :type preferred_app_group_type: str or - ~desktop_virtualization_api_client.models.PreferredAppGroupType - :param start_vm_on_connect: The flag to turn on/off StartVMOnConnect feature. - :type start_vm_on_connect: bool - :param migration_request: The registration info of HostPool. - :type migration_request: ~desktop_virtualization_api_client.models.MigrationRequestProperties - :ivar cloud_pc_resource: Is cloud pc resource. - :vartype cloud_pc_resource: bool - :param public_network_access: Enabled allows this resource to be accessed from both public and - private networks, Disabled allows this resource to only be accessed via private endpoints. - Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~desktop_virtualization_api_client.models.PublicNetworkAccess - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'host_pool_type': {'required': True}, - 'load_balancer_type': {'required': True}, - 'application_group_references': {'readonly': True}, - 'preferred_app_group_type': {'required': True}, - 'cloud_pc_resource': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'host_pool_type': {'key': 'properties.hostPoolType', 'type': 'str'}, - 'personal_desktop_assignment_type': {'key': 'properties.personalDesktopAssignmentType', 'type': 'str'}, - 'custom_rdp_property': {'key': 'properties.customRdpProperty', 'type': 'str'}, - 'max_session_limit': {'key': 'properties.maxSessionLimit', 'type': 'int'}, - 'load_balancer_type': {'key': 'properties.loadBalancerType', 'type': 'str'}, - 'ring': {'key': 'properties.ring', 'type': 'int'}, - 'validation_environment': {'key': 'properties.validationEnvironment', 'type': 'bool'}, - 'registration_info': {'key': 'properties.registrationInfo', 'type': 'RegistrationInfo'}, - 'vm_template': {'key': 'properties.vmTemplate', 'type': 'str'}, - 'application_group_references': {'key': 'properties.applicationGroupReferences', 'type': '[str]'}, - 'ssoadfs_authority': {'key': 'properties.ssoadfsAuthority', 'type': 'str'}, - 'sso_client_id': {'key': 'properties.ssoClientId', 'type': 'str'}, - 'sso_client_secret_key_vault_path': {'key': 'properties.ssoClientSecretKeyVaultPath', 'type': 'str'}, - 'sso_secret_type': {'key': 'properties.ssoSecretType', 'type': 'str'}, - 'preferred_app_group_type': {'key': 'properties.preferredAppGroupType', 'type': 'str'}, - 'start_vm_on_connect': {'key': 'properties.startVMOnConnect', 'type': 'bool'}, - 'migration_request': {'key': 'properties.migrationRequest', 'type': 'MigrationRequestProperties'}, - 'cloud_pc_resource': {'key': 'properties.cloudPcResource', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HostPool, self).__init__(**kwargs) - self.system_data = None - self.object_id = None - self.friendly_name = kwargs.get('friendly_name', None) - self.description = kwargs.get('description', None) - self.host_pool_type = kwargs['host_pool_type'] - self.personal_desktop_assignment_type = kwargs.get('personal_desktop_assignment_type', None) - self.custom_rdp_property = kwargs.get('custom_rdp_property', None) - self.max_session_limit = kwargs.get('max_session_limit', None) - self.load_balancer_type = kwargs['load_balancer_type'] - self.ring = kwargs.get('ring', None) - self.validation_environment = kwargs.get('validation_environment', None) - self.registration_info = kwargs.get('registration_info', None) - self.vm_template = kwargs.get('vm_template', None) - self.application_group_references = None - self.ssoadfs_authority = kwargs.get('ssoadfs_authority', None) - self.sso_client_id = kwargs.get('sso_client_id', None) - self.sso_client_secret_key_vault_path = kwargs.get('sso_client_secret_key_vault_path', None) - self.sso_secret_type = kwargs.get('sso_secret_type', None) - self.preferred_app_group_type = kwargs['preferred_app_group_type'] - self.start_vm_on_connect = kwargs.get('start_vm_on_connect', None) - self.migration_request = kwargs.get('migration_request', None) - self.cloud_pc_resource = None - self.public_network_access = kwargs.get('public_network_access', None) - - -class HostPoolList(msrest.serialization.Model): - """List of HostPool definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of HostPool definitions. - :type value: list[~desktop_virtualization_api_client.models.HostPool] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[HostPool]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HostPoolList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class HostPoolPatch(Resource): - """HostPool properties that can be patched. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param friendly_name: Friendly name of HostPool. - :type friendly_name: str - :param description: Description of HostPool. - :type description: str - :param custom_rdp_property: Custom rdp property of HostPool. - :type custom_rdp_property: str - :param max_session_limit: The max session limit of HostPool. - :type max_session_limit: int - :param personal_desktop_assignment_type: PersonalDesktopAssignment type for HostPool. Possible - values include: "Automatic", "Direct". - :type personal_desktop_assignment_type: str or - ~desktop_virtualization_api_client.models.PersonalDesktopAssignmentType - :param load_balancer_type: The type of the load balancer. Possible values include: - "BreadthFirst", "DepthFirst", "Persistent". - :type load_balancer_type: str or ~desktop_virtualization_api_client.models.LoadBalancerType - :param ring: The ring number of HostPool. - :type ring: int - :param validation_environment: Is validation environment. - :type validation_environment: bool - :param registration_info: The registration info of HostPool. - :type registration_info: ~desktop_virtualization_api_client.models.RegistrationInfoPatch - :param vm_template: VM template for sessionhosts configuration within hostpool. - :type vm_template: str - :param ssoadfs_authority: URL to customer ADFS server for signing WVD SSO certificates. - :type ssoadfs_authority: str - :param sso_client_id: ClientId for the registered Relying Party used to issue WVD SSO - certificates. - :type sso_client_id: str - :param sso_client_secret_key_vault_path: Path to Azure KeyVault storing the secret used for - communication to ADFS. - :type sso_client_secret_key_vault_path: str - :param sso_secret_type: The type of single sign on Secret Type. Possible values include: - "SharedKey", "Certificate", "SharedKeyInKeyVault", "CertificateInKeyVault". - :type sso_secret_type: str or ~desktop_virtualization_api_client.models.SSOSecretType - :param preferred_app_group_type: The type of preferred application group type, default to - Desktop Application Group. Possible values include: "None", "Desktop", "RailApplications". - :type preferred_app_group_type: str or - ~desktop_virtualization_api_client.models.PreferredAppGroupType - :param start_vm_on_connect: The flag to turn on/off StartVMOnConnect feature. - :type start_vm_on_connect: bool - :param public_network_access: Enabled to allow this resource to be access from the public - network. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~desktop_virtualization_api_client.models.PublicNetworkAccess - """ - - _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'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'custom_rdp_property': {'key': 'properties.customRdpProperty', 'type': 'str'}, - 'max_session_limit': {'key': 'properties.maxSessionLimit', 'type': 'int'}, - 'personal_desktop_assignment_type': {'key': 'properties.personalDesktopAssignmentType', 'type': 'str'}, - 'load_balancer_type': {'key': 'properties.loadBalancerType', 'type': 'str'}, - 'ring': {'key': 'properties.ring', 'type': 'int'}, - 'validation_environment': {'key': 'properties.validationEnvironment', 'type': 'bool'}, - 'registration_info': {'key': 'properties.registrationInfo', 'type': 'RegistrationInfoPatch'}, - 'vm_template': {'key': 'properties.vmTemplate', 'type': 'str'}, - 'ssoadfs_authority': {'key': 'properties.ssoadfsAuthority', 'type': 'str'}, - 'sso_client_id': {'key': 'properties.ssoClientId', 'type': 'str'}, - 'sso_client_secret_key_vault_path': {'key': 'properties.ssoClientSecretKeyVaultPath', 'type': 'str'}, - 'sso_secret_type': {'key': 'properties.ssoSecretType', 'type': 'str'}, - 'preferred_app_group_type': {'key': 'properties.preferredAppGroupType', 'type': 'str'}, - 'start_vm_on_connect': {'key': 'properties.startVMOnConnect', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HostPoolPatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.description = kwargs.get('description', None) - self.custom_rdp_property = kwargs.get('custom_rdp_property', None) - self.max_session_limit = kwargs.get('max_session_limit', None) - self.personal_desktop_assignment_type = kwargs.get('personal_desktop_assignment_type', None) - self.load_balancer_type = kwargs.get('load_balancer_type', None) - self.ring = kwargs.get('ring', None) - self.validation_environment = kwargs.get('validation_environment', None) - self.registration_info = kwargs.get('registration_info', None) - self.vm_template = kwargs.get('vm_template', None) - self.ssoadfs_authority = kwargs.get('ssoadfs_authority', None) - self.sso_client_id = kwargs.get('sso_client_id', None) - self.sso_client_secret_key_vault_path = kwargs.get('sso_client_secret_key_vault_path', None) - self.sso_secret_type = kwargs.get('sso_secret_type', None) - self.preferred_app_group_type = kwargs.get('preferred_app_group_type', None) - self.start_vm_on_connect = kwargs.get('start_vm_on_connect', None) - self.public_network_access = kwargs.get('public_network_access', None) - - -class Identity(msrest.serialization.Model): - """Identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. - :type type: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Identity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - - -class LogSpecification(msrest.serialization.Model): - """Specifications of the Log for Azure Monitoring. - - :param name: Name of the log. - :type name: str - :param display_name: Localized friendly display name of the log. - :type display_name: str - :param blob_duration: Blob duration of the log. - :type blob_duration: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSpecification, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.blob_duration = kwargs.get('blob_duration', None) - - -class MigrationRequestProperties(msrest.serialization.Model): - """Properties for arm migration. - - :param operation: The type of operation for migration. Possible values include: "Start", - "Revoke", "Complete", "Hide", "Unhide". - :type operation: str or ~desktop_virtualization_api_client.models.Operation - :param migration_path: The path to the legacy object to migrate. - :type migration_path: str - """ - - _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'migration_path': {'key': 'migrationPath', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationRequestProperties, self).__init__(**kwargs) - self.operation = kwargs.get('operation', None) - self.migration_path = kwargs.get('migration_path', None) - - -class MSIXImageURI(msrest.serialization.Model): - """Represents URI referring to MSIX Image. - - :param uri: URI to Image. - :type uri: str - """ - - _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MSIXImageURI, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) - - -class MSIXPackage(Resource): - """Schema for MSIX Package properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :param image_path: VHD/CIM image path on Network Share. - :type image_path: str - :param package_name: Package Name from appxmanifest.xml. - :type package_name: str - :param package_family_name: Package Family Name from appxmanifest.xml. Contains Package Name - and Publisher name. - :type package_family_name: str - :param display_name: User friendly Name to be displayed in the portal. - :type display_name: str - :param package_relative_path: Relative Path to the package inside the image. - :type package_relative_path: str - :param is_regular_registration: Specifies how to register Package in feed. - :type is_regular_registration: bool - :param is_active: Make this version of the package the active one across the hostpool. - :type is_active: bool - :param package_dependencies: List of package dependencies. - :type package_dependencies: - list[~desktop_virtualization_api_client.models.MsixPackageDependencies] - :param version: Package Version found in the appxmanifest.xml. - :type version: str - :param last_updated: Date Package was last updated, found in the appxmanifest.xml. - :type last_updated: ~datetime.datetime - :param package_applications: List of package applications. - :type package_applications: - list[~desktop_virtualization_api_client.models.MsixPackageApplications] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'image_path': {'key': 'properties.imagePath', 'type': 'str'}, - 'package_name': {'key': 'properties.packageName', 'type': 'str'}, - 'package_family_name': {'key': 'properties.packageFamilyName', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'package_relative_path': {'key': 'properties.packageRelativePath', 'type': 'str'}, - 'is_regular_registration': {'key': 'properties.isRegularRegistration', 'type': 'bool'}, - 'is_active': {'key': 'properties.isActive', 'type': 'bool'}, - 'package_dependencies': {'key': 'properties.packageDependencies', 'type': '[MsixPackageDependencies]'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'last_updated': {'key': 'properties.lastUpdated', 'type': 'iso-8601'}, - 'package_applications': {'key': 'properties.packageApplications', 'type': '[MsixPackageApplications]'}, - } - - def __init__( - self, - **kwargs - ): - super(MSIXPackage, self).__init__(**kwargs) - self.system_data = None - self.image_path = kwargs.get('image_path', None) - self.package_name = kwargs.get('package_name', None) - self.package_family_name = kwargs.get('package_family_name', None) - self.display_name = kwargs.get('display_name', None) - self.package_relative_path = kwargs.get('package_relative_path', None) - self.is_regular_registration = kwargs.get('is_regular_registration', None) - self.is_active = kwargs.get('is_active', None) - self.package_dependencies = kwargs.get('package_dependencies', None) - self.version = kwargs.get('version', None) - self.last_updated = kwargs.get('last_updated', None) - self.package_applications = kwargs.get('package_applications', None) - - -class MsixPackageApplications(msrest.serialization.Model): - """Schema for MSIX Package Application properties. - - :param app_id: Package Application Id, found in appxmanifest.xml. - :type app_id: str - :param description: Description of Package Application. - :type description: str - :param app_user_model_id: Used to activate Package Application. Consists of Package Name and - ApplicationID. Found in appxmanifest.xml. - :type app_user_model_id: str - :param friendly_name: User friendly name. - :type friendly_name: str - :param icon_image_name: User friendly name. - :type icon_image_name: str - :param raw_icon: the icon a 64 bit string as a byte array. - :type raw_icon: bytearray - :param raw_png: the icon a 64 bit string as a byte array. - :type raw_png: bytearray - """ - - _attribute_map = { - 'app_id': {'key': 'appId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'app_user_model_id': {'key': 'appUserModelID', 'type': 'str'}, - 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, - 'icon_image_name': {'key': 'iconImageName', 'type': 'str'}, - 'raw_icon': {'key': 'rawIcon', 'type': 'bytearray'}, - 'raw_png': {'key': 'rawPng', 'type': 'bytearray'}, - } - - def __init__( - self, - **kwargs - ): - super(MsixPackageApplications, self).__init__(**kwargs) - self.app_id = kwargs.get('app_id', None) - self.description = kwargs.get('description', None) - self.app_user_model_id = kwargs.get('app_user_model_id', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.icon_image_name = kwargs.get('icon_image_name', None) - self.raw_icon = kwargs.get('raw_icon', None) - self.raw_png = kwargs.get('raw_png', None) - - -class MsixPackageDependencies(msrest.serialization.Model): - """Schema for MSIX Package Dependencies properties. - - :param dependency_name: Name of package dependency. - :type dependency_name: str - :param publisher: Name of dependency publisher. - :type publisher: str - :param min_version: Dependency version required. - :type min_version: str - """ - - _attribute_map = { - 'dependency_name': {'key': 'dependencyName', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'min_version': {'key': 'minVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MsixPackageDependencies, self).__init__(**kwargs) - self.dependency_name = kwargs.get('dependency_name', None) - self.publisher = kwargs.get('publisher', None) - self.min_version = kwargs.get('min_version', None) - - -class MSIXPackageList(msrest.serialization.Model): - """List of MSIX Package definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of MSIX Package definitions. - :type value: list[~desktop_virtualization_api_client.models.MSIXPackage] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MSIXPackage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MSIXPackageList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MSIXPackagePatch(Resource): - """MSIX Package properties that can be patched. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param is_active: Set a version of the package to be active across hostpool. - :type is_active: bool - :param is_regular_registration: Set Registration mode. Regular or Delayed. - :type is_regular_registration: bool - :param display_name: Display name for MSIX Package. - :type display_name: 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'}, - 'is_active': {'key': 'properties.isActive', 'type': 'bool'}, - 'is_regular_registration': {'key': 'properties.isRegularRegistration', 'type': 'bool'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MSIXPackagePatch, self).__init__(**kwargs) - self.is_active = kwargs.get('is_active', None) - self.is_regular_registration = kwargs.get('is_regular_registration', None) - self.display_name = kwargs.get('display_name', None) - - -class OperationProperties(msrest.serialization.Model): - """Properties of the operation. - - :param service_specification: Service specification payload. - :type service_specification: ~desktop_virtualization_api_client.models.ServiceSpecification - """ - - _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationProperties, self).__init__(**kwargs) - self.service_specification = kwargs.get('service_specification', None) - - -class Plan(msrest.serialization.Model): - """Plan for the resource. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. A user defined name of the 3rd Party Artifact that is being procured. - :type name: str - :param publisher: Required. The publisher of the 3rd Party Artifact that is being bought. E.g. - NewRelic. - :type publisher: str - :param product: Required. The 3rd Party artifact that is being procured. E.g. NewRelic. Product - maps to the OfferID specified for the artifact at the time of Data Market onboarding. - :type product: str - :param promotion_code: A publisher provided promotion code as provisioned in Data Market for - the said product/artifact. - :type promotion_code: str - :param version: The version of the desired product/artifact. - :type version: str - """ - - _validation = { - 'name': {'required': True}, - 'publisher': {'required': True}, - 'product': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Plan, self).__init__(**kwargs) - self.name = kwargs['name'] - self.publisher = kwargs['publisher'] - self.product = kwargs['product'] - self.promotion_code = kwargs.get('promotion_code', None) - self.version = kwargs.get('version', None) - - -class PrivateEndpoint(msrest.serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(Resource): - """The Private Endpoint Connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param private_endpoint: The resource of private end point. - :type private_endpoint: ~desktop_virtualization_api_client.models.PrivateEndpoint - :param private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :type private_link_service_connection_state: - ~desktop_virtualization_api_client.models.PrivateLinkServiceConnectionState - :param provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". - :type provisioning_state: str or - ~desktop_virtualization_api_client.models.PrivateEndpointConnectionProvisioningState - """ - - _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'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - - -class PrivateEndpointConnectionListResultWithSystemData(msrest.serialization.Model): - """List of private endpoint connection associated with the specified storage account. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Array of private endpoint connections. - :type value: - list[~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnectionWithSystemData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResultWithSystemData, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class PrivateEndpointConnectionWithSystemData(PrivateEndpointConnection): - """The Private Endpoint Connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param private_endpoint: The resource of private end point. - :type private_endpoint: ~desktop_virtualization_api_client.models.PrivateEndpoint - :param private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :type private_link_service_connection_state: - ~desktop_virtualization_api_client.models.PrivateLinkServiceConnectionState - :param provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". - :type provisioning_state: str or - ~desktop_virtualization_api_client.models.PrivateEndpointConnectionProvisioningState - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionWithSystemData, self).__init__(**kwargs) - self.system_data = None - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :param required_zone_names: The private link resource Private link DNS zone name. - :type required_zone_names: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class PrivateLinkResourceListResult(msrest.serialization.Model): - """A list of private link resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Array of private link resources. - :type value: list[~desktop_virtualization_api_client.models.PrivateLinkResource] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """A collection of information about the state of the connection between service consumer and provider. - - :param status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". - :type status: str or - ~desktop_virtualization_api_client.models.PrivateEndpointServiceConnectionStatus - :param description: The reason for approval/rejection of the connection. - :type description: str - :param actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :type actions_required: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.description = kwargs.get('description', None) - self.actions_required = kwargs.get('actions_required', None) - - -class RegistrationInfo(msrest.serialization.Model): - """Represents a RegistrationInfo definition. - - :param expiration_time: Expiration time of registration token. - :type expiration_time: ~datetime.datetime - :param token: The registration token base64 encoded string. - :type token: str - :param registration_token_operation: The type of resetting the token. Possible values include: - "Delete", "None", "Update". - :type registration_token_operation: str or - ~desktop_virtualization_api_client.models.RegistrationTokenOperation - """ - - _attribute_map = { - 'expiration_time': {'key': 'expirationTime', 'type': 'iso-8601'}, - 'token': {'key': 'token', 'type': 'str'}, - 'registration_token_operation': {'key': 'registrationTokenOperation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationInfo, self).__init__(**kwargs) - self.expiration_time = kwargs.get('expiration_time', None) - self.token = kwargs.get('token', None) - self.registration_token_operation = kwargs.get('registration_token_operation', None) - - -class RegistrationInfoPatch(msrest.serialization.Model): - """Represents a RegistrationInfo definition. - - :param expiration_time: Expiration time of registration token. - :type expiration_time: ~datetime.datetime - :param registration_token_operation: The type of resetting the token. Possible values include: - "Delete", "None", "Update". - :type registration_token_operation: str or - ~desktop_virtualization_api_client.models.RegistrationTokenOperation - """ - - _attribute_map = { - 'expiration_time': {'key': 'expirationTime', 'type': 'iso-8601'}, - 'registration_token_operation': {'key': 'registrationTokenOperation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationInfoPatch, self).__init__(**kwargs) - self.expiration_time = kwargs.get('expiration_time', None) - self.registration_token_operation = kwargs.get('registration_token_operation', None) - - -class ResourceModelWithAllowedPropertySetIdentity(Identity): - """ResourceModelWithAllowedPropertySetIdentity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. - :type type: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceModelWithAllowedPropertySetIdentity, self).__init__(**kwargs) - - -class ResourceModelWithAllowedPropertySetPlan(Plan): - """ResourceModelWithAllowedPropertySetPlan. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. A user defined name of the 3rd Party Artifact that is being procured. - :type name: str - :param publisher: Required. The publisher of the 3rd Party Artifact that is being bought. E.g. - NewRelic. - :type publisher: str - :param product: Required. The 3rd Party artifact that is being procured. E.g. NewRelic. Product - maps to the OfferID specified for the artifact at the time of Data Market onboarding. - :type product: str - :param promotion_code: A publisher provided promotion code as provisioned in Data Market for - the said product/artifact. - :type promotion_code: str - :param version: The version of the desired product/artifact. - :type version: str - """ - - _validation = { - 'name': {'required': True}, - 'publisher': {'required': True}, - 'product': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceModelWithAllowedPropertySetPlan, self).__init__(**kwargs) - - -class Sku(msrest.serialization.Model): - """The resource model definition representing SKU. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. - :type name: str - :param 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". - :type tier: str or ~desktop_virtualization_api_client.models.SkuTier - :param size: The SKU size. When the name field is the combination of tier and some other value, - this would be the standalone code. - :type size: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :param 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. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - '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, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - self.size = kwargs.get('size', None) - self.family = kwargs.get('family', None) - self.capacity = kwargs.get('capacity', None) - - -class ResourceModelWithAllowedPropertySetSku(Sku): - """ResourceModelWithAllowedPropertySetSku. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. - :type name: str - :param 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". - :type tier: str or ~desktop_virtualization_api_client.models.SkuTier - :param size: The SKU size. When the name field is the combination of tier and some other value, - this would be the standalone code. - :type size: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :param 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. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - '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, - **kwargs - ): - super(ResourceModelWithAllowedPropertySetSku, self).__init__(**kwargs) - - -class ResourceProviderOperation(msrest.serialization.Model): - """Supported operation of this resource provider. - - :param name: Operation name, in format of {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~desktop_virtualization_api_client.models.ResourceProviderOperationDisplay - :param is_data_action: Is a data action. - :type is_data_action: bool - :param properties: Properties of the operation. - :type properties: ~desktop_virtualization_api_client.models.OperationProperties - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.properties = kwargs.get('properties', None) - - -class ResourceProviderOperationDisplay(msrest.serialization.Model): - """Display metadata associated with the operation. - - :param provider: Resource provider: Microsoft Desktop Virtualization. - :type provider: str - :param resource: Resource on which the operation is performed. - :type resource: str - :param operation: Type of operation: get, read, delete, etc. - :type operation: str - :param description: Description of this 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(ResourceProviderOperationDisplay, 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 ResourceProviderOperationList(msrest.serialization.Model): - """Result of the request to list operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of operations supported by this resource provider. - :type value: list[~desktop_virtualization_api_client.models.ResourceProviderOperation] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ScalingHostPoolReference(msrest.serialization.Model): - """Scaling plan reference to hostpool. - - :param host_pool_arm_path: Arm path of referenced hostpool. - :type host_pool_arm_path: str - :param scaling_plan_enabled: Is the scaling plan enabled for this hostpool. - :type scaling_plan_enabled: bool - """ - - _attribute_map = { - 'host_pool_arm_path': {'key': 'hostPoolArmPath', 'type': 'str'}, - 'scaling_plan_enabled': {'key': 'scalingPlanEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ScalingHostPoolReference, self).__init__(**kwargs) - self.host_pool_arm_path = kwargs.get('host_pool_arm_path', None) - self.scaling_plan_enabled = kwargs.get('scaling_plan_enabled', None) - - -class ScalingPlan(ResourceModelWithAllowedPropertySet): - """Represents a scaling plan definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. - Indicates if this resource is managed by another Azure resource. If this is present, complete - mode deployment will not delete the resource if it is removed from the template since it is - managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :ivar object_id: ObjectId of scaling plan. (internal use). - :vartype object_id: str - :param description: Description of scaling plan. - :type description: str - :param friendly_name: User friendly name of scaling plan. - :type friendly_name: str - :param time_zone: Timezone of the scaling plan. - :type time_zone: str - :param host_pool_type: HostPool type for desktop. Possible values include: "Pooled". - :type host_pool_type: str or ~desktop_virtualization_api_client.models.ScalingHostPoolType - :param exclusion_tag: Exclusion tag for scaling plan. - :type exclusion_tag: str - :param schedules: List of ScalingSchedule definitions. - :type schedules: list[~desktop_virtualization_api_client.models.ScalingSchedule] - :param host_pool_references: List of ScalingHostPoolReference definitions. - :type host_pool_references: - list[~desktop_virtualization_api_client.models.ScalingHostPoolReference] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'host_pool_type': {'key': 'properties.hostPoolType', 'type': 'str'}, - 'exclusion_tag': {'key': 'properties.exclusionTag', 'type': 'str'}, - 'schedules': {'key': 'properties.schedules', 'type': '[ScalingSchedule]'}, - 'host_pool_references': {'key': 'properties.hostPoolReferences', 'type': '[ScalingHostPoolReference]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScalingPlan, self).__init__(**kwargs) - self.system_data = None - self.object_id = None - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.time_zone = kwargs.get('time_zone', None) - self.host_pool_type = kwargs.get('host_pool_type', None) - self.exclusion_tag = kwargs.get('exclusion_tag', None) - self.schedules = kwargs.get('schedules', None) - self.host_pool_references = kwargs.get('host_pool_references', None) - - -class ScalingPlanList(msrest.serialization.Model): - """List of scaling plan definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of scaling plan definitions. - :type value: list[~desktop_virtualization_api_client.models.ScalingPlan] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ScalingPlan]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScalingPlanList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ScalingPlanPatch(msrest.serialization.Model): - """Scaling plan properties that can be patched. - - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of scaling plan. - :type description: str - :param friendly_name: User friendly name of scaling plan. - :type friendly_name: str - :param time_zone: Timezone of the scaling plan. - :type time_zone: str - :param exclusion_tag: Exclusion tag for scaling plan. - :type exclusion_tag: str - :param schedules: List of ScalingSchedule definitions. - :type schedules: list[~desktop_virtualization_api_client.models.ScalingSchedule] - :param host_pool_references: List of ScalingHostPoolReference definitions. - :type host_pool_references: - list[~desktop_virtualization_api_client.models.ScalingHostPoolReference] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'exclusion_tag': {'key': 'properties.exclusionTag', 'type': 'str'}, - 'schedules': {'key': 'properties.schedules', 'type': '[ScalingSchedule]'}, - 'host_pool_references': {'key': 'properties.hostPoolReferences', 'type': '[ScalingHostPoolReference]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScalingPlanPatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.time_zone = kwargs.get('time_zone', None) - self.exclusion_tag = kwargs.get('exclusion_tag', None) - self.schedules = kwargs.get('schedules', None) - self.host_pool_references = kwargs.get('host_pool_references', None) - - -class ScalingSchedule(msrest.serialization.Model): - """Scaling plan schedule. - - :param name: Name of the scaling schedule. - :type name: str - :param days_of_week: Set of days of the week on which this schedule is active. - :type days_of_week: list[str or - ~desktop_virtualization_api_client.models.ScalingScheduleDaysOfWeekItem] - :param ramp_up_start_time: Starting time for ramp up period. - :type ramp_up_start_time: ~desktop_virtualization_api_client.models.Time - :param ramp_up_load_balancing_algorithm: Load balancing algorithm for ramp up period. Possible - values include: "BreadthFirst", "DepthFirst". - :type ramp_up_load_balancing_algorithm: str or - ~desktop_virtualization_api_client.models.SessionHostLoadBalancingAlgorithm - :param ramp_up_minimum_hosts_pct: Minimum host percentage for ramp up period. - :type ramp_up_minimum_hosts_pct: int - :param ramp_up_capacity_threshold_pct: Capacity threshold for ramp up period. - :type ramp_up_capacity_threshold_pct: int - :param peak_start_time: Starting time for peak period. - :type peak_start_time: ~desktop_virtualization_api_client.models.Time - :param peak_load_balancing_algorithm: Load balancing algorithm for peak period. Possible values - include: "BreadthFirst", "DepthFirst". - :type peak_load_balancing_algorithm: str or - ~desktop_virtualization_api_client.models.SessionHostLoadBalancingAlgorithm - :param ramp_down_start_time: Starting time for ramp down period. - :type ramp_down_start_time: ~desktop_virtualization_api_client.models.Time - :param ramp_down_load_balancing_algorithm: Load balancing algorithm for ramp down period. - Possible values include: "BreadthFirst", "DepthFirst". - :type ramp_down_load_balancing_algorithm: str or - ~desktop_virtualization_api_client.models.SessionHostLoadBalancingAlgorithm - :param ramp_down_minimum_hosts_pct: Minimum host percentage for ramp down period. - :type ramp_down_minimum_hosts_pct: int - :param ramp_down_capacity_threshold_pct: Capacity threshold for ramp down period. - :type ramp_down_capacity_threshold_pct: int - :param ramp_down_force_logoff_users: Should users be logged off forcefully from hosts. - :type ramp_down_force_logoff_users: bool - :param ramp_down_stop_hosts_when: Specifies when to stop hosts during ramp down period. - Possible values include: "ZeroSessions", "ZeroActiveSessions". - :type ramp_down_stop_hosts_when: str or ~desktop_virtualization_api_client.models.StopHostsWhen - :param ramp_down_wait_time_minutes: Number of minutes to wait to stop hosts during ramp down - period. - :type ramp_down_wait_time_minutes: int - :param ramp_down_notification_message: Notification message for users during ramp down period. - :type ramp_down_notification_message: str - :param off_peak_start_time: Starting time for off-peak period. - :type off_peak_start_time: ~desktop_virtualization_api_client.models.Time - :param off_peak_load_balancing_algorithm: Load balancing algorithm for off-peak period. - Possible values include: "BreadthFirst", "DepthFirst". - :type off_peak_load_balancing_algorithm: str or - ~desktop_virtualization_api_client.models.SessionHostLoadBalancingAlgorithm - """ - - _validation = { - 'ramp_up_minimum_hosts_pct': {'maximum': 100, 'minimum': 0}, - 'ramp_up_capacity_threshold_pct': {'maximum': 100, 'minimum': 1}, - 'ramp_down_minimum_hosts_pct': {'maximum': 100, 'minimum': 0}, - 'ramp_down_capacity_threshold_pct': {'maximum': 100, 'minimum': 0}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'days_of_week': {'key': 'daysOfWeek', 'type': '[str]'}, - 'ramp_up_start_time': {'key': 'rampUpStartTime', 'type': 'Time'}, - 'ramp_up_load_balancing_algorithm': {'key': 'rampUpLoadBalancingAlgorithm', 'type': 'str'}, - 'ramp_up_minimum_hosts_pct': {'key': 'rampUpMinimumHostsPct', 'type': 'int'}, - 'ramp_up_capacity_threshold_pct': {'key': 'rampUpCapacityThresholdPct', 'type': 'int'}, - 'peak_start_time': {'key': 'peakStartTime', 'type': 'Time'}, - 'peak_load_balancing_algorithm': {'key': 'peakLoadBalancingAlgorithm', 'type': 'str'}, - 'ramp_down_start_time': {'key': 'rampDownStartTime', 'type': 'Time'}, - 'ramp_down_load_balancing_algorithm': {'key': 'rampDownLoadBalancingAlgorithm', 'type': 'str'}, - 'ramp_down_minimum_hosts_pct': {'key': 'rampDownMinimumHostsPct', 'type': 'int'}, - 'ramp_down_capacity_threshold_pct': {'key': 'rampDownCapacityThresholdPct', 'type': 'int'}, - 'ramp_down_force_logoff_users': {'key': 'rampDownForceLogoffUsers', 'type': 'bool'}, - 'ramp_down_stop_hosts_when': {'key': 'rampDownStopHostsWhen', 'type': 'str'}, - 'ramp_down_wait_time_minutes': {'key': 'rampDownWaitTimeMinutes', 'type': 'int'}, - 'ramp_down_notification_message': {'key': 'rampDownNotificationMessage', 'type': 'str'}, - 'off_peak_start_time': {'key': 'offPeakStartTime', 'type': 'Time'}, - 'off_peak_load_balancing_algorithm': {'key': 'offPeakLoadBalancingAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScalingSchedule, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.days_of_week = kwargs.get('days_of_week', None) - self.ramp_up_start_time = kwargs.get('ramp_up_start_time', None) - self.ramp_up_load_balancing_algorithm = kwargs.get('ramp_up_load_balancing_algorithm', None) - self.ramp_up_minimum_hosts_pct = kwargs.get('ramp_up_minimum_hosts_pct', None) - self.ramp_up_capacity_threshold_pct = kwargs.get('ramp_up_capacity_threshold_pct', None) - self.peak_start_time = kwargs.get('peak_start_time', None) - self.peak_load_balancing_algorithm = kwargs.get('peak_load_balancing_algorithm', None) - self.ramp_down_start_time = kwargs.get('ramp_down_start_time', None) - self.ramp_down_load_balancing_algorithm = kwargs.get('ramp_down_load_balancing_algorithm', None) - self.ramp_down_minimum_hosts_pct = kwargs.get('ramp_down_minimum_hosts_pct', None) - self.ramp_down_capacity_threshold_pct = kwargs.get('ramp_down_capacity_threshold_pct', None) - self.ramp_down_force_logoff_users = kwargs.get('ramp_down_force_logoff_users', None) - self.ramp_down_stop_hosts_when = kwargs.get('ramp_down_stop_hosts_when', None) - self.ramp_down_wait_time_minutes = kwargs.get('ramp_down_wait_time_minutes', None) - self.ramp_down_notification_message = kwargs.get('ramp_down_notification_message', None) - self.off_peak_start_time = kwargs.get('off_peak_start_time', None) - self.off_peak_load_balancing_algorithm = kwargs.get('off_peak_load_balancing_algorithm', None) - - -class SendMessage(msrest.serialization.Model): - """Represents message sent to a UserSession. - - :param message_title: Title of message. - :type message_title: str - :param message_body: Body of message. - :type message_body: str - """ - - _attribute_map = { - 'message_title': {'key': 'messageTitle', 'type': 'str'}, - 'message_body': {'key': 'messageBody', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SendMessage, self).__init__(**kwargs) - self.message_title = kwargs.get('message_title', None) - self.message_body = kwargs.get('message_body', None) - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification payload. - - :param log_specifications: Specifications of the Log for Azure Monitoring. - :type log_specifications: list[~desktop_virtualization_api_client.models.LogSpecification] - """ - - _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.log_specifications = kwargs.get('log_specifications', None) - - -class SessionHost(Resource): - """Represents a SessionHost definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :ivar object_id: ObjectId of SessionHost. (internal use). - :vartype object_id: str - :param last_heart_beat: Last heart beat from SessionHost. - :type last_heart_beat: ~datetime.datetime - :param sessions: Number of sessions on SessionHost. - :type sessions: int - :param agent_version: Version of agent on SessionHost. - :type agent_version: str - :param allow_new_session: Allow a new session. - :type allow_new_session: bool - :ivar virtual_machine_id: Virtual Machine Id of SessionHost's underlying virtual machine. - :vartype virtual_machine_id: str - :ivar resource_id: Resource Id of SessionHost's underlying virtual machine. - :vartype resource_id: str - :param assigned_user: User assigned to SessionHost. - :type assigned_user: str - :param status: Status for a SessionHost. Possible values include: "Available", "Unavailable", - "Shutdown", "Disconnected", "Upgrading", "UpgradeFailed", "NoHeartbeat", "NotJoinedToDomain", - "DomainTrustRelationshipLost", "SxSStackListenerNotReady", "FSLogixNotHealthy", - "NeedsAssistance". - :type status: str or ~desktop_virtualization_api_client.models.Status - :ivar status_timestamp: The timestamp of the status. - :vartype status_timestamp: ~datetime.datetime - :param os_version: The version of the OS on the session host. - :type os_version: str - :param sx_s_stack_version: The version of the side by side stack on the session host. - :type sx_s_stack_version: str - :param update_state: Update state of a SessionHost. Possible values include: "Initial", - "Pending", "Started", "Succeeded", "Failed". - :type update_state: str or ~desktop_virtualization_api_client.models.UpdateState - :ivar last_update_time: The timestamp of the last update. - :vartype last_update_time: ~datetime.datetime - :param update_error_message: The error message. - :type update_error_message: str - :ivar session_host_health_check_results: List of SessionHostHealthCheckReports. - :vartype session_host_health_check_results: - list[~desktop_virtualization_api_client.models.SessionHostHealthCheckReport] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'virtual_machine_id': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'status_timestamp': {'readonly': True}, - 'last_update_time': {'readonly': True}, - 'session_host_health_check_results': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'last_heart_beat': {'key': 'properties.lastHeartBeat', 'type': 'iso-8601'}, - 'sessions': {'key': 'properties.sessions', 'type': 'int'}, - 'agent_version': {'key': 'properties.agentVersion', 'type': 'str'}, - 'allow_new_session': {'key': 'properties.allowNewSession', 'type': 'bool'}, - 'virtual_machine_id': {'key': 'properties.virtualMachineId', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'assigned_user': {'key': 'properties.assignedUser', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_timestamp': {'key': 'properties.statusTimestamp', 'type': 'iso-8601'}, - 'os_version': {'key': 'properties.osVersion', 'type': 'str'}, - 'sx_s_stack_version': {'key': 'properties.sxSStackVersion', 'type': 'str'}, - 'update_state': {'key': 'properties.updateState', 'type': 'str'}, - 'last_update_time': {'key': 'properties.lastUpdateTime', 'type': 'iso-8601'}, - 'update_error_message': {'key': 'properties.updateErrorMessage', 'type': 'str'}, - 'session_host_health_check_results': {'key': 'properties.sessionHostHealthCheckResults', 'type': '[SessionHostHealthCheckReport]'}, - } - - def __init__( - self, - **kwargs - ): - super(SessionHost, self).__init__(**kwargs) - self.system_data = None - self.object_id = None - self.last_heart_beat = kwargs.get('last_heart_beat', None) - self.sessions = kwargs.get('sessions', None) - self.agent_version = kwargs.get('agent_version', None) - self.allow_new_session = kwargs.get('allow_new_session', None) - self.virtual_machine_id = None - self.resource_id = None - self.assigned_user = kwargs.get('assigned_user', None) - self.status = kwargs.get('status', None) - self.status_timestamp = None - self.os_version = kwargs.get('os_version', None) - self.sx_s_stack_version = kwargs.get('sx_s_stack_version', None) - self.update_state = kwargs.get('update_state', None) - self.last_update_time = None - self.update_error_message = kwargs.get('update_error_message', None) - self.session_host_health_check_results = None - - -class SessionHostHealthCheckFailureDetails(msrest.serialization.Model): - """Contains details on the failure. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Failure message: hints on what is wrong and how to recover. - :vartype message: str - :ivar error_code: Error code corresponding for the failure. - :vartype error_code: int - :ivar last_health_check_date_time: The timestamp of the last update. - :vartype last_health_check_date_time: ~datetime.datetime - """ - - _validation = { - 'message': {'readonly': True}, - 'error_code': {'readonly': True}, - 'last_health_check_date_time': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'int'}, - 'last_health_check_date_time': {'key': 'lastHealthCheckDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SessionHostHealthCheckFailureDetails, self).__init__(**kwargs) - self.message = None - self.error_code = None - self.last_health_check_date_time = None - - -class SessionHostHealthCheckReport(msrest.serialization.Model): - """The report for session host information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar health_check_name: Represents the name of the health check operation performed. Possible - values include: "DomainJoinedCheck", "DomainTrustCheck", "FSLogixHealthCheck", - "SxSStackListenerCheck", "UrlsAccessibleCheck", "MonitoringAgentCheck", "DomainReachable", - "WebRTCRedirectorCheck", "SupportedEncryptionCheck", "MetaDataServiceCheck", - "AppAttachHealthCheck". - :vartype health_check_name: str or ~desktop_virtualization_api_client.models.HealthCheckName - :ivar health_check_result: Represents the Health state of the health check we performed. - Possible values include: "Unknown", "HealthCheckSucceeded", "HealthCheckFailed", - "SessionHostShutdown". - :vartype health_check_result: str or - ~desktop_virtualization_api_client.models.HealthCheckResult - :ivar additional_failure_details: Additional detailed information on the failure. - :vartype additional_failure_details: - ~desktop_virtualization_api_client.models.SessionHostHealthCheckFailureDetails - """ - - _validation = { - 'health_check_name': {'readonly': True}, - 'health_check_result': {'readonly': True}, - 'additional_failure_details': {'readonly': True}, - } - - _attribute_map = { - 'health_check_name': {'key': 'healthCheckName', 'type': 'str'}, - 'health_check_result': {'key': 'healthCheckResult', 'type': 'str'}, - 'additional_failure_details': {'key': 'additionalFailureDetails', 'type': 'SessionHostHealthCheckFailureDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(SessionHostHealthCheckReport, self).__init__(**kwargs) - self.health_check_name = None - self.health_check_result = None - self.additional_failure_details = None - - -class SessionHostList(msrest.serialization.Model): - """List of SessionHost definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of SessionHost definitions. - :type value: list[~desktop_virtualization_api_client.models.SessionHost] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SessionHost]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SessionHostList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class SessionHostPatch(Resource): - """SessionHost properties that can be patched. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param allow_new_session: Allow a new session. - :type allow_new_session: bool - :param assigned_user: User assigned to SessionHost. - :type assigned_user: 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'}, - 'allow_new_session': {'key': 'properties.allowNewSession', 'type': 'bool'}, - 'assigned_user': {'key': 'properties.assignedUser', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SessionHostPatch, self).__init__(**kwargs) - self.allow_new_session = kwargs.get('allow_new_session', None) - self.assigned_user = kwargs.get('assigned_user', None) - - -class StartMenuItem(Resource): - """Represents a StartMenuItem definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param app_alias: Alias of StartMenuItem. - :type app_alias: str - :param file_path: Path to the file of StartMenuItem. - :type file_path: str - :param command_line_arguments: Command line arguments for StartMenuItem. - :type command_line_arguments: str - :param icon_path: Path to the icon. - :type icon_path: str - :param icon_index: Index of the icon. - :type icon_index: int - """ - - _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'}, - 'app_alias': {'key': 'properties.appAlias', 'type': 'str'}, - 'file_path': {'key': 'properties.filePath', 'type': 'str'}, - 'command_line_arguments': {'key': 'properties.commandLineArguments', 'type': 'str'}, - 'icon_path': {'key': 'properties.iconPath', 'type': 'str'}, - 'icon_index': {'key': 'properties.iconIndex', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(StartMenuItem, self).__init__(**kwargs) - self.app_alias = kwargs.get('app_alias', None) - self.file_path = kwargs.get('file_path', None) - self.command_line_arguments = kwargs.get('command_line_arguments', None) - self.icon_path = kwargs.get('icon_path', None) - self.icon_index = kwargs.get('icon_index', None) - - -class StartMenuItemList(msrest.serialization.Model): - """List of StartMenuItem definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of StartMenuItem definitions. - :type value: list[~desktop_virtualization_api_client.models.StartMenuItem] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StartMenuItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StartMenuItemList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~desktop_virtualization_api_client.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~desktop_virtualization_api_client.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class Time(msrest.serialization.Model): - """The time for a scaling action to occur. - - All required parameters must be populated in order to send to Azure. - - :param hour: Required. The hour. - :type hour: int - :param minute: Required. The minute. - :type minute: int - """ - - _validation = { - 'hour': {'required': True, 'maximum': 23, 'minimum': 0}, - 'minute': {'required': True, 'maximum': 59, 'minimum': 0}, - } - - _attribute_map = { - 'hour': {'key': 'hour', 'type': 'int'}, - 'minute': {'key': 'minute', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Time, self).__init__(**kwargs) - self.hour = kwargs['hour'] - self.minute = kwargs['minute'] - - -class UserSession(Resource): - """Represents a UserSession definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :ivar object_id: ObjectId of user session. (internal use). - :vartype object_id: str - :param user_principal_name: The user principal name. - :type user_principal_name: str - :param application_type: Application type of application. Possible values include: "RemoteApp", - "Desktop". - :type application_type: str or ~desktop_virtualization_api_client.models.ApplicationType - :param session_state: State of user session. Possible values include: "Unknown", "Active", - "Disconnected", "Pending", "LogOff", "UserProfileDiskMounted". - :type session_state: str or ~desktop_virtualization_api_client.models.SessionState - :param active_directory_user_name: The active directory user name. - :type active_directory_user_name: str - :param create_time: The timestamp of the user session create. - :type create_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'user_principal_name': {'key': 'properties.userPrincipalName', 'type': 'str'}, - 'application_type': {'key': 'properties.applicationType', 'type': 'str'}, - 'session_state': {'key': 'properties.sessionState', 'type': 'str'}, - 'active_directory_user_name': {'key': 'properties.activeDirectoryUserName', 'type': 'str'}, - 'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(UserSession, self).__init__(**kwargs) - self.system_data = None - self.object_id = None - self.user_principal_name = kwargs.get('user_principal_name', None) - self.application_type = kwargs.get('application_type', None) - self.session_state = kwargs.get('session_state', None) - self.active_directory_user_name = kwargs.get('active_directory_user_name', None) - self.create_time = kwargs.get('create_time', None) - - -class UserSessionList(msrest.serialization.Model): - """List of UserSession definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of UserSession definitions. - :type value: list[~desktop_virtualization_api_client.models.UserSession] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSession]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserSessionList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class Workspace(ResourceModelWithAllowedPropertySet): - """Represents a Workspace definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. - Indicates if this resource is managed by another Azure resource. If this is present, complete - mode deployment will not delete the resource if it is removed from the template since it is - managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :ivar object_id: ObjectId of Workspace. (internal use). - :vartype object_id: str - :param description: Description of Workspace. - :type description: str - :param friendly_name: Friendly name of Workspace. - :type friendly_name: str - :param application_group_references: List of applicationGroup resource Ids. - :type application_group_references: list[str] - :ivar cloud_pc_resource: Is cloud pc resource. - :vartype cloud_pc_resource: bool - :param public_network_access: Enabled allows this resource to be accessed from both public and - private networks, Disabled allows this resource to only be accessed via private endpoints. - Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~desktop_virtualization_api_client.models.PublicNetworkAccess - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'cloud_pc_resource': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'application_group_references': {'key': 'properties.applicationGroupReferences', 'type': '[str]'}, - 'cloud_pc_resource': {'key': 'properties.cloudPcResource', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Workspace, self).__init__(**kwargs) - self.system_data = None - self.object_id = None - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.application_group_references = kwargs.get('application_group_references', None) - self.cloud_pc_resource = None - self.public_network_access = kwargs.get('public_network_access', None) - - -class WorkspaceList(msrest.serialization.Model): - """List of Workspace definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Workspace definitions. - :type value: list[~desktop_virtualization_api_client.models.Workspace] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Workspace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkspaceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class WorkspacePatch(msrest.serialization.Model): - """Workspace properties that can be patched. - - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of Workspace. - :type description: str - :param friendly_name: Friendly name of Workspace. - :type friendly_name: str - :param application_group_references: List of applicationGroup links. - :type application_group_references: list[str] - :param public_network_access: Enabled to allow this resource to be access from the public - network. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~desktop_virtualization_api_client.models.PublicNetworkAccess - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'application_group_references': {'key': 'properties.applicationGroupReferences', 'type': '[str]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkspacePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.description = kwargs.get('description', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.application_group_references = kwargs.get('application_group_references', None) - self.public_network_access = kwargs.get('public_network_access', None) diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_models_py3.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_models_py3.py index 9af6a672aa43..9c2c595aafef 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_models_py3.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,132 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +import sys +from typing import Dict, List, Optional, TYPE_CHECKING, Union + +from .. import _serialization + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class AgentUpdatePatchProperties(_serialization.Model): + """The session host configuration for updating agent, monitoring agent, and stack component. + + :ivar type: The type of maintenance for session host components. Known values are: "Default" + and "Scheduled". + :vartype type: str or ~azure.mgmt.desktopvirtualization.models.SessionHostComponentUpdateType + :ivar use_session_host_local_time: Whether to use localTime of the virtual machine. + :vartype use_session_host_local_time: bool + :ivar maintenance_window_time_zone: Time zone for maintenance as defined in + https://docs.microsoft.com/en-us/dotnet/api/system.timezoneinfo.findsystemtimezonebyid?view=net-5.0. + Must be set if useLocalTime is true. + :vartype maintenance_window_time_zone: str + :ivar maintenance_windows: List of maintenance windows. Maintenance windows are 2 hours long. + :vartype maintenance_windows: + list[~azure.mgmt.desktopvirtualization.models.MaintenanceWindowPatchProperties] + """ -import msrest.serialization + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "use_session_host_local_time": {"key": "useSessionHostLocalTime", "type": "bool"}, + "maintenance_window_time_zone": {"key": "maintenanceWindowTimeZone", "type": "str"}, + "maintenance_windows": {"key": "maintenanceWindows", "type": "[MaintenanceWindowPatchProperties]"}, + } -from ._desktop_virtualization_api_client_enums import * + def __init__( + self, + *, + type: Optional[Union[str, "_models.SessionHostComponentUpdateType"]] = None, + use_session_host_local_time: Optional[bool] = None, + maintenance_window_time_zone: Optional[str] = None, + maintenance_windows: Optional[List["_models.MaintenanceWindowPatchProperties"]] = None, + **kwargs + ): + """ + :keyword type: The type of maintenance for session host components. Known values are: "Default" + and "Scheduled". + :paramtype type: str or ~azure.mgmt.desktopvirtualization.models.SessionHostComponentUpdateType + :keyword use_session_host_local_time: Whether to use localTime of the virtual machine. + :paramtype use_session_host_local_time: bool + :keyword maintenance_window_time_zone: Time zone for maintenance as defined in + https://docs.microsoft.com/en-us/dotnet/api/system.timezoneinfo.findsystemtimezonebyid?view=net-5.0. + Must be set if useLocalTime is true. + :paramtype maintenance_window_time_zone: str + :keyword maintenance_windows: List of maintenance windows. Maintenance windows are 2 hours + long. + :paramtype maintenance_windows: + list[~azure.mgmt.desktopvirtualization.models.MaintenanceWindowPatchProperties] + """ + super().__init__(**kwargs) + self.type = type + self.use_session_host_local_time = use_session_host_local_time + self.maintenance_window_time_zone = maintenance_window_time_zone + self.maintenance_windows = maintenance_windows + + +class AgentUpdateProperties(_serialization.Model): + """The session host configuration for updating agent, monitoring agent, and stack component. + + :ivar type: The type of maintenance for session host components. Known values are: "Default" + and "Scheduled". + :vartype type: str or ~azure.mgmt.desktopvirtualization.models.SessionHostComponentUpdateType + :ivar use_session_host_local_time: Whether to use localTime of the virtual machine. + :vartype use_session_host_local_time: bool + :ivar maintenance_window_time_zone: Time zone for maintenance as defined in + https://docs.microsoft.com/en-us/dotnet/api/system.timezoneinfo.findsystemtimezonebyid?view=net-5.0. + Must be set if useLocalTime is true. + :vartype maintenance_window_time_zone: str + :ivar maintenance_windows: List of maintenance windows. Maintenance windows are 2 hours long. + :vartype maintenance_windows: + list[~azure.mgmt.desktopvirtualization.models.MaintenanceWindowProperties] + """ + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "use_session_host_local_time": {"key": "useSessionHostLocalTime", "type": "bool"}, + "maintenance_window_time_zone": {"key": "maintenanceWindowTimeZone", "type": "str"}, + "maintenance_windows": {"key": "maintenanceWindows", "type": "[MaintenanceWindowProperties]"}, + } -class Resource(msrest.serialization.Model): + def __init__( + self, + *, + type: Optional[Union[str, "_models.SessionHostComponentUpdateType"]] = None, + use_session_host_local_time: Optional[bool] = None, + maintenance_window_time_zone: Optional[str] = None, + maintenance_windows: Optional[List["_models.MaintenanceWindowProperties"]] = None, + **kwargs + ): + """ + :keyword type: The type of maintenance for session host components. Known values are: "Default" + and "Scheduled". + :paramtype type: str or ~azure.mgmt.desktopvirtualization.models.SessionHostComponentUpdateType + :keyword use_session_host_local_time: Whether to use localTime of the virtual machine. + :paramtype use_session_host_local_time: bool + :keyword maintenance_window_time_zone: Time zone for maintenance as defined in + https://docs.microsoft.com/en-us/dotnet/api/system.timezoneinfo.findsystemtimezonebyid?view=net-5.0. + Must be set if useLocalTime is true. + :paramtype maintenance_window_time_zone: str + :keyword maintenance_windows: List of maintenance windows. Maintenance windows are 2 hours + long. + :paramtype maintenance_windows: + list[~azure.mgmt.desktopvirtualization.models.MaintenanceWindowProperties] + """ + super().__init__(**kwargs) + self.type = type + self.use_session_host_local_time = use_session_host_local_time + self.maintenance_window_time_zone = maintenance_window_time_zone + self.maintenance_windows = maintenance_windows + + +class Resource(_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. @@ -30,28 +149,26 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class Application(Resource): +class Application(Resource): # pylint: disable=too-many-instance-attributes """Schema for Application properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -67,91 +184,125 @@ class Application(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData :ivar object_id: ObjectId of Application. (internal use). :vartype object_id: str - :param description: Description of Application. - :type description: str - :param friendly_name: Friendly name of Application. - :type friendly_name: str - :param file_path: Specifies a path for the executable file for the application. - :type file_path: str - :param msix_package_family_name: Specifies the package family name for MSIX applications. - :type msix_package_family_name: str - :param msix_package_application_id: Specifies the package application Id for MSIX applications. - :type msix_package_application_id: str - :param application_type: Resource Type of Application. Possible values include: "InBuilt", + :ivar description: Description of Application. + :vartype description: str + :ivar friendly_name: Friendly name of Application. + :vartype friendly_name: str + :ivar file_path: Specifies a path for the executable file for the application. + :vartype file_path: str + :ivar msix_package_family_name: Specifies the package family name for MSIX applications. + :vartype msix_package_family_name: str + :ivar msix_package_application_id: Specifies the package application Id for MSIX applications. + :vartype msix_package_application_id: str + :ivar application_type: Resource Type of Application. Known values are: "InBuilt" and "MsixApplication". - :type application_type: str or ~desktop_virtualization_api_client.models.RemoteApplicationType - :param command_line_setting: Required. Specifies whether this published application can be - launched with command line arguments provided by the client, command line arguments specified - at publish time, or no command line arguments at all. Possible values include: "DoNotAllow", - "Allow", "Require". - :type command_line_setting: str or ~desktop_virtualization_api_client.models.CommandLineSetting - :param command_line_arguments: Command Line Arguments for Application. - :type command_line_arguments: str - :param show_in_portal: Specifies whether to show the RemoteApp program in the RD Web Access + :vartype application_type: str or + ~azure.mgmt.desktopvirtualization.models.RemoteApplicationType + :ivar command_line_setting: Specifies whether this published application can be launched with + command line arguments provided by the client, command line arguments specified at publish + time, or no command line arguments at all. Required. Known values are: "DoNotAllow", "Allow", + and "Require". + :vartype command_line_setting: str or + ~azure.mgmt.desktopvirtualization.models.CommandLineSetting + :ivar command_line_arguments: Command Line Arguments for Application. + :vartype command_line_arguments: str + :ivar show_in_portal: Specifies whether to show the RemoteApp program in the RD Web Access server. - :type show_in_portal: bool - :param icon_path: Path to icon. - :type icon_path: str - :param icon_index: Index of the icon. - :type icon_index: int + :vartype show_in_portal: bool + :ivar icon_path: Path to icon. + :vartype icon_path: str + :ivar icon_index: Index of the icon. + :vartype icon_index: int :ivar icon_hash: Hash of the icon. :vartype icon_hash: str :ivar icon_content: the icon a 64 bit string as a byte array. - :vartype icon_content: bytearray + :vartype icon_content: bytes """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'command_line_setting': {'required': True}, - 'icon_hash': {'readonly': True}, - 'icon_content': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'file_path': {'key': 'properties.filePath', 'type': 'str'}, - 'msix_package_family_name': {'key': 'properties.msixPackageFamilyName', 'type': 'str'}, - 'msix_package_application_id': {'key': 'properties.msixPackageApplicationId', 'type': 'str'}, - 'application_type': {'key': 'properties.applicationType', 'type': 'str'}, - 'command_line_setting': {'key': 'properties.commandLineSetting', 'type': 'str'}, - 'command_line_arguments': {'key': 'properties.commandLineArguments', 'type': 'str'}, - 'show_in_portal': {'key': 'properties.showInPortal', 'type': 'bool'}, - 'icon_path': {'key': 'properties.iconPath', 'type': 'str'}, - 'icon_index': {'key': 'properties.iconIndex', 'type': 'int'}, - 'icon_hash': {'key': 'properties.iconHash', 'type': 'str'}, - 'icon_content': {'key': 'properties.iconContent', 'type': 'bytearray'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "object_id": {"readonly": True}, + "command_line_setting": {"required": True}, + "icon_hash": {"readonly": True}, + "icon_content": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "file_path": {"key": "properties.filePath", "type": "str"}, + "msix_package_family_name": {"key": "properties.msixPackageFamilyName", "type": "str"}, + "msix_package_application_id": {"key": "properties.msixPackageApplicationId", "type": "str"}, + "application_type": {"key": "properties.applicationType", "type": "str"}, + "command_line_setting": {"key": "properties.commandLineSetting", "type": "str"}, + "command_line_arguments": {"key": "properties.commandLineArguments", "type": "str"}, + "show_in_portal": {"key": "properties.showInPortal", "type": "bool"}, + "icon_path": {"key": "properties.iconPath", "type": "str"}, + "icon_index": {"key": "properties.iconIndex", "type": "int"}, + "icon_hash": {"key": "properties.iconHash", "type": "str"}, + "icon_content": {"key": "properties.iconContent", "type": "bytearray"}, } def __init__( self, *, - command_line_setting: Union[str, "CommandLineSetting"], + command_line_setting: Union[str, "_models.CommandLineSetting"], description: Optional[str] = None, friendly_name: Optional[str] = None, file_path: Optional[str] = None, msix_package_family_name: Optional[str] = None, msix_package_application_id: Optional[str] = None, - application_type: Optional[Union[str, "RemoteApplicationType"]] = None, + application_type: Optional[Union[str, "_models.RemoteApplicationType"]] = None, command_line_arguments: Optional[str] = None, show_in_portal: Optional[bool] = None, icon_path: Optional[str] = None, icon_index: Optional[int] = None, **kwargs ): - super(Application, self).__init__(**kwargs) + """ + :keyword description: Description of Application. + :paramtype description: str + :keyword friendly_name: Friendly name of Application. + :paramtype friendly_name: str + :keyword file_path: Specifies a path for the executable file for the application. + :paramtype file_path: str + :keyword msix_package_family_name: Specifies the package family name for MSIX applications. + :paramtype msix_package_family_name: str + :keyword msix_package_application_id: Specifies the package application Id for MSIX + applications. + :paramtype msix_package_application_id: str + :keyword application_type: Resource Type of Application. Known values are: "InBuilt" and + "MsixApplication". + :paramtype application_type: str or + ~azure.mgmt.desktopvirtualization.models.RemoteApplicationType + :keyword command_line_setting: Specifies whether this published application can be launched + with command line arguments provided by the client, command line arguments specified at publish + time, or no command line arguments at all. Required. Known values are: "DoNotAllow", "Allow", + and "Require". + :paramtype command_line_setting: str or + ~azure.mgmt.desktopvirtualization.models.CommandLineSetting + :keyword command_line_arguments: Command Line Arguments for Application. + :paramtype command_line_arguments: str + :keyword show_in_portal: Specifies whether to show the RemoteApp program in the RD Web Access + server. + :paramtype show_in_portal: bool + :keyword icon_path: Path to icon. + :paramtype icon_path: str + :keyword icon_index: Index of the icon. + :paramtype icon_index: int + """ + super().__init__(**kwargs) self.system_data = None self.object_id = None self.description = description @@ -169,7 +320,7 @@ def __init__( self.icon_content = None -class ResourceModelWithAllowedPropertySet(msrest.serialization.Model): +class ResourceModelWithAllowedPropertySet(_serialization.Model): # pylint: disable=too-many-instance-attributes """The resource model definition containing the full set of allowed properties for a resource. Except properties bag, there cannot be a top level property outside of this set. Variables are only populated by the server, and will be ignored when sending a request. @@ -182,54 +333,54 @@ class ResourceModelWithAllowedPropertySet(msrest.serialization.Model): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar managed_by: The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :vartype managed_by: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar etag: The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: + :vartype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :ivar sku: + :vartype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :ivar plan: + :vartype plan: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceModelWithAllowedPropertySetIdentity"}, + "sku": {"key": "sku", "type": "ResourceModelWithAllowedPropertySetSku"}, + "plan": {"key": "plan", "type": "ResourceModelWithAllowedPropertySetPlan"}, } def __init__( @@ -239,12 +390,35 @@ def __init__( managed_by: Optional[str] = None, kind: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceModelWithAllowedPropertySetIdentity"] = None, - sku: Optional["ResourceModelWithAllowedPropertySetSku"] = None, - plan: Optional["ResourceModelWithAllowedPropertySetPlan"] = None, + identity: Optional["_models.ResourceModelWithAllowedPropertySetIdentity"] = None, + sku: Optional["_models.ResourceModelWithAllowedPropertySetSku"] = None, + plan: Optional["_models.ResourceModelWithAllowedPropertySetPlan"] = None, **kwargs ): - super(ResourceModelWithAllowedPropertySet, self).__init__(**kwargs) + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword managed_by: The fully qualified resource ID of the resource that manages this + resource. Indicates if this resource is managed by another Azure resource. If this is present, + complete mode deployment will not delete the resource if it is removed from the template since + it is managed by another resource. + :paramtype managed_by: str + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: + :paramtype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :keyword sku: + :paramtype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :keyword plan: + :paramtype plan: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -258,7 +432,7 @@ def __init__( self.plan = plan -class ApplicationGroup(ResourceModelWithAllowedPropertySet): +class ApplicationGroup(ResourceModelWithAllowedPropertySet): # pylint: disable=too-many-instance-attributes """Represents a ApplicationGroup definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -273,109 +447,147 @@ class ApplicationGroup(ResourceModelWithAllowedPropertySet): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar managed_by: The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :vartype managed_by: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar etag: The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: + :vartype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :ivar sku: + :vartype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :ivar plan: + :vartype plan: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData :ivar object_id: ObjectId of ApplicationGroup. (internal use). :vartype object_id: str - :param description: Description of ApplicationGroup. - :type description: str - :param friendly_name: Friendly name of ApplicationGroup. - :type friendly_name: str - :param host_pool_arm_path: Required. HostPool arm path of ApplicationGroup. - :type host_pool_arm_path: str + :ivar description: Description of ApplicationGroup. + :vartype description: str + :ivar friendly_name: Friendly name of ApplicationGroup. + :vartype friendly_name: str + :ivar host_pool_arm_path: HostPool arm path of ApplicationGroup. Required. + :vartype host_pool_arm_path: str :ivar workspace_arm_path: Workspace arm path of ApplicationGroup. :vartype workspace_arm_path: str - :param application_group_type: Required. Resource Type of ApplicationGroup. Possible values - include: "RemoteApp", "Desktop". - :type application_group_type: str or - ~desktop_virtualization_api_client.models.ApplicationGroupType - :param migration_request: The registration info of HostPool. - :type migration_request: ~desktop_virtualization_api_client.models.MigrationRequestProperties + :ivar application_group_type: Resource Type of ApplicationGroup. Required. Known values are: + "RemoteApp" and "Desktop". + :vartype application_group_type: str or + ~azure.mgmt.desktopvirtualization.models.ApplicationGroupType :ivar cloud_pc_resource: Is cloud pc resource. :vartype cloud_pc_resource: bool """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'host_pool_arm_path': {'required': True}, - 'workspace_arm_path': {'readonly': True}, - 'application_group_type': {'required': True}, - 'cloud_pc_resource': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'host_pool_arm_path': {'key': 'properties.hostPoolArmPath', 'type': 'str'}, - 'workspace_arm_path': {'key': 'properties.workspaceArmPath', 'type': 'str'}, - 'application_group_type': {'key': 'properties.applicationGroupType', 'type': 'str'}, - 'migration_request': {'key': 'properties.migrationRequest', 'type': 'MigrationRequestProperties'}, - 'cloud_pc_resource': {'key': 'properties.cloudPcResource', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "object_id": {"readonly": True}, + "host_pool_arm_path": {"required": True}, + "workspace_arm_path": {"readonly": True}, + "application_group_type": {"required": True}, + "cloud_pc_resource": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceModelWithAllowedPropertySetIdentity"}, + "sku": {"key": "sku", "type": "ResourceModelWithAllowedPropertySetSku"}, + "plan": {"key": "plan", "type": "ResourceModelWithAllowedPropertySetPlan"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "host_pool_arm_path": {"key": "properties.hostPoolArmPath", "type": "str"}, + "workspace_arm_path": {"key": "properties.workspaceArmPath", "type": "str"}, + "application_group_type": {"key": "properties.applicationGroupType", "type": "str"}, + "cloud_pc_resource": {"key": "properties.cloudPcResource", "type": "bool"}, } def __init__( self, *, host_pool_arm_path: str, - application_group_type: Union[str, "ApplicationGroupType"], + application_group_type: Union[str, "_models.ApplicationGroupType"], location: Optional[str] = None, managed_by: Optional[str] = None, kind: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceModelWithAllowedPropertySetIdentity"] = None, - sku: Optional["ResourceModelWithAllowedPropertySetSku"] = None, - plan: Optional["ResourceModelWithAllowedPropertySetPlan"] = None, + identity: Optional["_models.ResourceModelWithAllowedPropertySetIdentity"] = None, + sku: Optional["_models.ResourceModelWithAllowedPropertySetSku"] = None, + plan: Optional["_models.ResourceModelWithAllowedPropertySetPlan"] = None, description: Optional[str] = None, friendly_name: Optional[str] = None, - migration_request: Optional["MigrationRequestProperties"] = None, **kwargs ): - super(ApplicationGroup, self).__init__(location=location, managed_by=managed_by, kind=kind, tags=tags, identity=identity, sku=sku, plan=plan, **kwargs) + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword managed_by: The fully qualified resource ID of the resource that manages this + resource. Indicates if this resource is managed by another Azure resource. If this is present, + complete mode deployment will not delete the resource if it is removed from the template since + it is managed by another resource. + :paramtype managed_by: str + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: + :paramtype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :keyword sku: + :paramtype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :keyword plan: + :paramtype plan: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan + :keyword description: Description of ApplicationGroup. + :paramtype description: str + :keyword friendly_name: Friendly name of ApplicationGroup. + :paramtype friendly_name: str + :keyword host_pool_arm_path: HostPool arm path of ApplicationGroup. Required. + :paramtype host_pool_arm_path: str + :keyword application_group_type: Resource Type of ApplicationGroup. Required. Known values are: + "RemoteApp" and "Desktop". + :paramtype application_group_type: str or + ~azure.mgmt.desktopvirtualization.models.ApplicationGroupType + """ + super().__init__( + location=location, + managed_by=managed_by, + kind=kind, + tags=tags, + identity=identity, + sku=sku, + plan=plan, + **kwargs + ) self.system_data = None self.object_id = None self.description = description @@ -383,37 +595,35 @@ def __init__( self.host_pool_arm_path = host_pool_arm_path self.workspace_arm_path = None self.application_group_type = application_group_type - self.migration_request = migration_request self.cloud_pc_resource = None -class ApplicationGroupList(msrest.serialization.Model): +class ApplicationGroupList(_serialization.Model): """List of ApplicationGroup definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of ApplicationGroup definitions. - :type value: list[~desktop_virtualization_api_client.models.ApplicationGroup] + :ivar value: List of ApplicationGroup definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.ApplicationGroup] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplicationGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApplicationGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ApplicationGroup"]] = None, - **kwargs - ): - super(ApplicationGroupList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.ApplicationGroup"]] = None, **kwargs): + """ + :keyword value: List of ApplicationGroup definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.ApplicationGroup] + """ + super().__init__(**kwargs) self.value = value self.next_link = None @@ -431,27 +641,27 @@ class ApplicationGroupPatch(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of ApplicationGroup. - :type description: str - :param friendly_name: Friendly name of ApplicationGroup. - :type friendly_name: str + :ivar tags: tags to be updated. + :vartype tags: dict[str, str] + :ivar description: Description of ApplicationGroup. + :vartype description: str + :ivar friendly_name: Friendly name of ApplicationGroup. + :vartype friendly_name: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, } def __init__( @@ -462,90 +672,99 @@ def __init__( friendly_name: Optional[str] = None, **kwargs ): - super(ApplicationGroupPatch, self).__init__(**kwargs) + """ + :keyword tags: tags to be updated. + :paramtype tags: dict[str, str] + :keyword description: Description of ApplicationGroup. + :paramtype description: str + :keyword friendly_name: Friendly name of ApplicationGroup. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) self.tags = tags self.description = description self.friendly_name = friendly_name -class ApplicationList(msrest.serialization.Model): +class ApplicationList(_serialization.Model): """List of Application definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Application definitions. - :type value: list[~desktop_virtualization_api_client.models.Application] + :ivar value: List of Application definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.Application] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Application]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Application]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Application"]] = None, - **kwargs - ): - super(ApplicationList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.Application"]] = None, **kwargs): + """ + :keyword value: List of Application definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.Application] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class ApplicationPatch(msrest.serialization.Model): +class ApplicationPatch(_serialization.Model): # pylint: disable=too-many-instance-attributes """Application properties that can be patched. - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of Application. - :type description: str - :param friendly_name: Friendly name of Application. - :type friendly_name: str - :param file_path: Specifies a path for the executable file for the application. - :type file_path: str - :param command_line_setting: Specifies whether this published application can be launched with + :ivar tags: tags to be updated. + :vartype tags: dict[str, str] + :ivar description: Description of Application. + :vartype description: str + :ivar friendly_name: Friendly name of Application. + :vartype friendly_name: str + :ivar file_path: Specifies a path for the executable file for the application. + :vartype file_path: str + :ivar command_line_setting: Specifies whether this published application can be launched with command line arguments provided by the client, command line arguments specified at publish - time, or no command line arguments at all. Possible values include: "DoNotAllow", "Allow", + time, or no command line arguments at all. Known values are: "DoNotAllow", "Allow", and "Require". - :type command_line_setting: str or ~desktop_virtualization_api_client.models.CommandLineSetting - :param command_line_arguments: Command Line Arguments for Application. - :type command_line_arguments: str - :param show_in_portal: Specifies whether to show the RemoteApp program in the RD Web Access + :vartype command_line_setting: str or + ~azure.mgmt.desktopvirtualization.models.CommandLineSetting + :ivar command_line_arguments: Command Line Arguments for Application. + :vartype command_line_arguments: str + :ivar show_in_portal: Specifies whether to show the RemoteApp program in the RD Web Access server. - :type show_in_portal: bool - :param icon_path: Path to icon. - :type icon_path: str - :param icon_index: Index of the icon. - :type icon_index: int - :param msix_package_family_name: Specifies the package family name for MSIX applications. - :type msix_package_family_name: str - :param msix_package_application_id: Specifies the package application Id for MSIX applications. - :type msix_package_application_id: str - :param application_type: Resource Type of Application. Possible values include: "InBuilt", + :vartype show_in_portal: bool + :ivar icon_path: Path to icon. + :vartype icon_path: str + :ivar icon_index: Index of the icon. + :vartype icon_index: int + :ivar msix_package_family_name: Specifies the package family name for MSIX applications. + :vartype msix_package_family_name: str + :ivar msix_package_application_id: Specifies the package application Id for MSIX applications. + :vartype msix_package_application_id: str + :ivar application_type: Resource Type of Application. Known values are: "InBuilt" and "MsixApplication". - :type application_type: str or ~desktop_virtualization_api_client.models.RemoteApplicationType + :vartype application_type: str or + ~azure.mgmt.desktopvirtualization.models.RemoteApplicationType """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'file_path': {'key': 'properties.filePath', 'type': 'str'}, - 'command_line_setting': {'key': 'properties.commandLineSetting', 'type': 'str'}, - 'command_line_arguments': {'key': 'properties.commandLineArguments', 'type': 'str'}, - 'show_in_portal': {'key': 'properties.showInPortal', 'type': 'bool'}, - 'icon_path': {'key': 'properties.iconPath', 'type': 'str'}, - 'icon_index': {'key': 'properties.iconIndex', 'type': 'int'}, - 'msix_package_family_name': {'key': 'properties.msixPackageFamilyName', 'type': 'str'}, - 'msix_package_application_id': {'key': 'properties.msixPackageApplicationId', 'type': 'str'}, - 'application_type': {'key': 'properties.applicationType', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "file_path": {"key": "properties.filePath", "type": "str"}, + "command_line_setting": {"key": "properties.commandLineSetting", "type": "str"}, + "command_line_arguments": {"key": "properties.commandLineArguments", "type": "str"}, + "show_in_portal": {"key": "properties.showInPortal", "type": "bool"}, + "icon_path": {"key": "properties.iconPath", "type": "str"}, + "icon_index": {"key": "properties.iconIndex", "type": "int"}, + "msix_package_family_name": {"key": "properties.msixPackageFamilyName", "type": "str"}, + "msix_package_application_id": {"key": "properties.msixPackageApplicationId", "type": "str"}, + "application_type": {"key": "properties.applicationType", "type": "str"}, } def __init__( @@ -555,17 +774,51 @@ def __init__( description: Optional[str] = None, friendly_name: Optional[str] = None, file_path: Optional[str] = None, - command_line_setting: Optional[Union[str, "CommandLineSetting"]] = None, + command_line_setting: Optional[Union[str, "_models.CommandLineSetting"]] = None, command_line_arguments: Optional[str] = None, show_in_portal: Optional[bool] = None, icon_path: Optional[str] = None, icon_index: Optional[int] = None, msix_package_family_name: Optional[str] = None, msix_package_application_id: Optional[str] = None, - application_type: Optional[Union[str, "RemoteApplicationType"]] = None, + application_type: Optional[Union[str, "_models.RemoteApplicationType"]] = None, **kwargs ): - super(ApplicationPatch, self).__init__(**kwargs) + """ + :keyword tags: tags to be updated. + :paramtype tags: dict[str, str] + :keyword description: Description of Application. + :paramtype description: str + :keyword friendly_name: Friendly name of Application. + :paramtype friendly_name: str + :keyword file_path: Specifies a path for the executable file for the application. + :paramtype file_path: str + :keyword command_line_setting: Specifies whether this published application can be launched + with command line arguments provided by the client, command line arguments specified at publish + time, or no command line arguments at all. Known values are: "DoNotAllow", "Allow", and + "Require". + :paramtype command_line_setting: str or + ~azure.mgmt.desktopvirtualization.models.CommandLineSetting + :keyword command_line_arguments: Command Line Arguments for Application. + :paramtype command_line_arguments: str + :keyword show_in_portal: Specifies whether to show the RemoteApp program in the RD Web Access + server. + :paramtype show_in_portal: bool + :keyword icon_path: Path to icon. + :paramtype icon_path: str + :keyword icon_index: Index of the icon. + :paramtype icon_index: int + :keyword msix_package_family_name: Specifies the package family name for MSIX applications. + :paramtype msix_package_family_name: str + :keyword msix_package_application_id: Specifies the package application Id for MSIX + applications. + :paramtype msix_package_application_id: str + :keyword application_type: Resource Type of Application. Known values are: "InBuilt" and + "MsixApplication". + :paramtype application_type: str or + ~azure.mgmt.desktopvirtualization.models.RemoteApplicationType + """ + super().__init__(**kwargs) self.tags = tags self.description = description self.friendly_name = friendly_name @@ -580,28 +833,28 @@ def __init__( self.application_type = application_type -class CloudErrorProperties(msrest.serialization.Model): +class CloudErrorProperties(_serialization.Model): """Cloud error object properties. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): - super(CloudErrorProperties, self).__init__(**kwargs) + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ + super().__init__(**kwargs) self.code = code self.message = message @@ -620,49 +873,49 @@ class Desktop(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData :ivar object_id: ObjectId of Desktop. (internal use). :vartype object_id: str - :param description: Description of Desktop. - :type description: str - :param friendly_name: Friendly name of Desktop. - :type friendly_name: str + :ivar description: Description of Desktop. + :vartype description: str + :ivar friendly_name: Friendly name of Desktop. + :vartype friendly_name: str :ivar icon_hash: Hash of the icon. :vartype icon_hash: str :ivar icon_content: The icon a 64 bit string as a byte array. - :vartype icon_content: bytearray + :vartype icon_content: bytes """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'icon_hash': {'readonly': True}, - 'icon_content': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "object_id": {"readonly": True}, + "icon_hash": {"readonly": True}, + "icon_content": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'icon_hash': {'key': 'properties.iconHash', 'type': 'str'}, - 'icon_content': {'key': 'properties.iconContent', 'type': 'bytearray'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "icon_hash": {"key": "properties.iconHash", "type": "str"}, + "icon_content": {"key": "properties.iconContent", "type": "bytearray"}, } - def __init__( - self, - *, - description: Optional[str] = None, - friendly_name: Optional[str] = None, - **kwargs - ): - super(Desktop, self).__init__(**kwargs) + def __init__(self, *, description: Optional[str] = None, friendly_name: Optional[str] = None, **kwargs): + """ + :keyword description: Description of Desktop. + :paramtype description: str + :keyword friendly_name: Friendly name of Desktop. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) self.system_data = None self.object_id = None self.description = description @@ -671,52 +924,51 @@ def __init__( self.icon_content = None -class DesktopList(msrest.serialization.Model): +class DesktopList(_serialization.Model): """List of Desktop definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Desktop definitions. - :type value: list[~desktop_virtualization_api_client.models.Desktop] + :ivar value: List of Desktop definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.Desktop] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Desktop]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Desktop]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Desktop"]] = None, - **kwargs - ): - super(DesktopList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.Desktop"]] = None, **kwargs): + """ + :keyword value: List of Desktop definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.Desktop] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class DesktopPatch(msrest.serialization.Model): +class DesktopPatch(_serialization.Model): """Desktop properties that can be patched. - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of Desktop. - :type description: str - :param friendly_name: Friendly name of Desktop. - :type friendly_name: str + :ivar tags: tags to be updated. + :vartype tags: dict[str, str] + :ivar description: Description of Desktop. + :vartype description: str + :ivar friendly_name: Friendly name of Desktop. + :vartype friendly_name: str """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, } def __init__( @@ -727,13 +979,21 @@ def __init__( friendly_name: Optional[str] = None, **kwargs ): - super(DesktopPatch, self).__init__(**kwargs) + """ + :keyword tags: tags to be updated. + :paramtype tags: dict[str, str] + :keyword description: Description of Desktop. + :paramtype description: str + :keyword friendly_name: Friendly name of Desktop. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) self.tags = tags self.description = description self.friendly_name = friendly_name -class ExpandMsixImage(Resource): +class ExpandMsixImage(Resource): # pylint: disable=too-many-instance-attributes """Represents the definition of contents retrieved after expanding the MSIX Image. Variables are only populated by the server, and will be ignored when sending a request. @@ -746,60 +1006,60 @@ class ExpandMsixImage(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param package_alias: Alias of MSIX Package. - :type package_alias: str - :param image_path: VHD/CIM image path on Network Share. - :type image_path: str - :param package_name: Package Name from appxmanifest.xml. - :type package_name: str - :param package_family_name: Package Family Name from appxmanifest.xml. Contains Package Name - and Publisher name. - :type package_family_name: str - :param package_full_name: Package Full Name from appxmanifest.xml. - :type package_full_name: str - :param display_name: User friendly Name to be displayed in the portal. - :type display_name: str - :param package_relative_path: Relative Path to the package inside the image. - :type package_relative_path: str - :param is_regular_registration: Specifies how to register Package in feed. - :type is_regular_registration: bool - :param is_active: Make this version of the package the active one across the hostpool. - :type is_active: bool - :param package_dependencies: List of package dependencies. - :type package_dependencies: - list[~desktop_virtualization_api_client.models.MsixPackageDependencies] - :param version: Package Version found in the appxmanifest.xml. - :type version: str - :param last_updated: Date Package was last updated, found in the appxmanifest.xml. - :type last_updated: ~datetime.datetime - :param package_applications: List of package applications. - :type package_applications: - list[~desktop_virtualization_api_client.models.MsixPackageApplications] + :ivar package_alias: Alias of MSIX Package. + :vartype package_alias: str + :ivar image_path: VHD/CIM image path on Network Share. + :vartype image_path: str + :ivar package_name: Package Name from appxmanifest.xml. + :vartype package_name: str + :ivar package_family_name: Package Family Name from appxmanifest.xml. Contains Package Name and + Publisher name. + :vartype package_family_name: str + :ivar package_full_name: Package Full Name from appxmanifest.xml. + :vartype package_full_name: str + :ivar display_name: User friendly Name to be displayed in the portal. + :vartype display_name: str + :ivar package_relative_path: Relative Path to the package inside the image. + :vartype package_relative_path: str + :ivar is_regular_registration: Specifies how to register Package in feed. + :vartype is_regular_registration: bool + :ivar is_active: Make this version of the package the active one across the hostpool. + :vartype is_active: bool + :ivar package_dependencies: List of package dependencies. + :vartype package_dependencies: + list[~azure.mgmt.desktopvirtualization.models.MsixPackageDependencies] + :ivar version: Package Version found in the appxmanifest.xml. + :vartype version: str + :ivar last_updated: Date Package was last updated, found in the appxmanifest.xml. + :vartype last_updated: ~datetime.datetime + :ivar package_applications: List of package applications. + :vartype package_applications: + list[~azure.mgmt.desktopvirtualization.models.MsixPackageApplications] """ _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'}, - 'package_alias': {'key': 'properties.packageAlias', 'type': 'str'}, - 'image_path': {'key': 'properties.imagePath', 'type': 'str'}, - 'package_name': {'key': 'properties.packageName', 'type': 'str'}, - 'package_family_name': {'key': 'properties.packageFamilyName', 'type': 'str'}, - 'package_full_name': {'key': 'properties.packageFullName', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'package_relative_path': {'key': 'properties.packageRelativePath', 'type': 'str'}, - 'is_regular_registration': {'key': 'properties.isRegularRegistration', 'type': 'bool'}, - 'is_active': {'key': 'properties.isActive', 'type': 'bool'}, - 'package_dependencies': {'key': 'properties.packageDependencies', 'type': '[MsixPackageDependencies]'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'last_updated': {'key': 'properties.lastUpdated', 'type': 'iso-8601'}, - 'package_applications': {'key': 'properties.packageApplications', 'type': '[MsixPackageApplications]'}, + "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"}, + "package_alias": {"key": "properties.packageAlias", "type": "str"}, + "image_path": {"key": "properties.imagePath", "type": "str"}, + "package_name": {"key": "properties.packageName", "type": "str"}, + "package_family_name": {"key": "properties.packageFamilyName", "type": "str"}, + "package_full_name": {"key": "properties.packageFullName", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "package_relative_path": {"key": "properties.packageRelativePath", "type": "str"}, + "is_regular_registration": {"key": "properties.isRegularRegistration", "type": "bool"}, + "is_active": {"key": "properties.isActive", "type": "bool"}, + "package_dependencies": {"key": "properties.packageDependencies", "type": "[MsixPackageDependencies]"}, + "version": {"key": "properties.version", "type": "str"}, + "last_updated": {"key": "properties.lastUpdated", "type": "iso-8601"}, + "package_applications": {"key": "properties.packageApplications", "type": "[MsixPackageApplications]"}, } def __init__( @@ -814,13 +1074,44 @@ def __init__( package_relative_path: Optional[str] = None, is_regular_registration: Optional[bool] = None, is_active: Optional[bool] = None, - package_dependencies: Optional[List["MsixPackageDependencies"]] = None, + package_dependencies: Optional[List["_models.MsixPackageDependencies"]] = None, version: Optional[str] = None, last_updated: Optional[datetime.datetime] = None, - package_applications: Optional[List["MsixPackageApplications"]] = None, + package_applications: Optional[List["_models.MsixPackageApplications"]] = None, **kwargs ): - super(ExpandMsixImage, self).__init__(**kwargs) + """ + :keyword package_alias: Alias of MSIX Package. + :paramtype package_alias: str + :keyword image_path: VHD/CIM image path on Network Share. + :paramtype image_path: str + :keyword package_name: Package Name from appxmanifest.xml. + :paramtype package_name: str + :keyword package_family_name: Package Family Name from appxmanifest.xml. Contains Package Name + and Publisher name. + :paramtype package_family_name: str + :keyword package_full_name: Package Full Name from appxmanifest.xml. + :paramtype package_full_name: str + :keyword display_name: User friendly Name to be displayed in the portal. + :paramtype display_name: str + :keyword package_relative_path: Relative Path to the package inside the image. + :paramtype package_relative_path: str + :keyword is_regular_registration: Specifies how to register Package in feed. + :paramtype is_regular_registration: bool + :keyword is_active: Make this version of the package the active one across the hostpool. + :paramtype is_active: bool + :keyword package_dependencies: List of package dependencies. + :paramtype package_dependencies: + list[~azure.mgmt.desktopvirtualization.models.MsixPackageDependencies] + :keyword version: Package Version found in the appxmanifest.xml. + :paramtype version: str + :keyword last_updated: Date Package was last updated, found in the appxmanifest.xml. + :paramtype last_updated: ~datetime.datetime + :keyword package_applications: List of package applications. + :paramtype package_applications: + list[~azure.mgmt.desktopvirtualization.models.MsixPackageApplications] + """ + super().__init__(**kwargs) self.package_alias = package_alias self.image_path = image_path self.package_name = package_name @@ -836,38 +1127,37 @@ def __init__( self.package_applications = package_applications -class ExpandMsixImageList(msrest.serialization.Model): +class ExpandMsixImageList(_serialization.Model): """List of MSIX package properties retrieved from MSIX Image expansion. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of MSIX package properties from give MSIX Image. - :type value: list[~desktop_virtualization_api_client.models.ExpandMsixImage] + :ivar value: List of MSIX package properties from give MSIX Image. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.ExpandMsixImage] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ExpandMsixImage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExpandMsixImage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ExpandMsixImage"]] = None, - **kwargs - ): - super(ExpandMsixImageList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.ExpandMsixImage"]] = None, **kwargs): + """ + :keyword value: List of MSIX package properties from give MSIX Image. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.ExpandMsixImage] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class HostPool(ResourceModelWithAllowedPropertySet): +class HostPool(ResourceModelWithAllowedPropertySet): # pylint: disable=too-many-instance-attributes """Represents a HostPool definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -882,177 +1172,250 @@ class HostPool(ResourceModelWithAllowedPropertySet): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar managed_by: The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :vartype managed_by: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar etag: The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: + :vartype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :ivar sku: + :vartype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :ivar plan: + :vartype plan: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData :ivar object_id: ObjectId of HostPool. (internal use). :vartype object_id: str - :param friendly_name: Friendly name of HostPool. - :type friendly_name: str - :param description: Description of HostPool. - :type description: str - :param host_pool_type: Required. HostPool type for desktop. Possible values include: - "Personal", "Pooled", "BYODesktop". - :type host_pool_type: str or ~desktop_virtualization_api_client.models.HostPoolType - :param personal_desktop_assignment_type: PersonalDesktopAssignment type for HostPool. Possible - values include: "Automatic", "Direct". - :type personal_desktop_assignment_type: str or - ~desktop_virtualization_api_client.models.PersonalDesktopAssignmentType - :param custom_rdp_property: Custom rdp property of HostPool. - :type custom_rdp_property: str - :param max_session_limit: The max session limit of HostPool. - :type max_session_limit: int - :param load_balancer_type: Required. The type of the load balancer. Possible values include: - "BreadthFirst", "DepthFirst", "Persistent". - :type load_balancer_type: str or ~desktop_virtualization_api_client.models.LoadBalancerType - :param ring: The ring number of HostPool. - :type ring: int - :param validation_environment: Is validation environment. - :type validation_environment: bool - :param registration_info: The registration info of HostPool. - :type registration_info: ~desktop_virtualization_api_client.models.RegistrationInfo - :param vm_template: VM template for sessionhosts configuration within hostpool. - :type vm_template: str + :ivar friendly_name: Friendly name of HostPool. + :vartype friendly_name: str + :ivar description: Description of HostPool. + :vartype description: str + :ivar host_pool_type: HostPool type for desktop. Required. Known values are: "Personal", + "Pooled", and "BYODesktop". + :vartype host_pool_type: str or ~azure.mgmt.desktopvirtualization.models.HostPoolType + :ivar personal_desktop_assignment_type: PersonalDesktopAssignment type for HostPool. Known + values are: "Automatic" and "Direct". + :vartype personal_desktop_assignment_type: str or + ~azure.mgmt.desktopvirtualization.models.PersonalDesktopAssignmentType + :ivar custom_rdp_property: Custom rdp property of HostPool. + :vartype custom_rdp_property: str + :ivar max_session_limit: The max session limit of HostPool. + :vartype max_session_limit: int + :ivar load_balancer_type: The type of the load balancer. Required. Known values are: + "BreadthFirst", "DepthFirst", and "Persistent". + :vartype load_balancer_type: str or ~azure.mgmt.desktopvirtualization.models.LoadBalancerType + :ivar ring: The ring number of HostPool. + :vartype ring: int + :ivar validation_environment: Is validation environment. + :vartype validation_environment: bool + :ivar registration_info: The registration info of HostPool. + :vartype registration_info: ~azure.mgmt.desktopvirtualization.models.RegistrationInfo + :ivar vm_template: VM template for sessionhosts configuration within hostpool. + :vartype vm_template: str :ivar application_group_references: List of applicationGroup links. :vartype application_group_references: list[str] - :param ssoadfs_authority: URL to customer ADFS server for signing WVD SSO certificates. - :type ssoadfs_authority: str - :param sso_client_id: ClientId for the registered Relying Party used to issue WVD SSO + :ivar ssoadfs_authority: URL to customer ADFS server for signing WVD SSO certificates. + :vartype ssoadfs_authority: str + :ivar sso_client_id: ClientId for the registered Relying Party used to issue WVD SSO certificates. - :type sso_client_id: str - :param sso_client_secret_key_vault_path: Path to Azure KeyVault storing the secret used for + :vartype sso_client_id: str + :ivar sso_client_secret_key_vault_path: Path to Azure KeyVault storing the secret used for communication to ADFS. - :type sso_client_secret_key_vault_path: str - :param sso_secret_type: The type of single sign on Secret Type. Possible values include: - "SharedKey", "Certificate", "SharedKeyInKeyVault", "CertificateInKeyVault". - :type sso_secret_type: str or ~desktop_virtualization_api_client.models.SSOSecretType - :param preferred_app_group_type: Required. The type of preferred application group type, - default to Desktop Application Group. Possible values include: "None", "Desktop", + :vartype sso_client_secret_key_vault_path: str + :ivar sso_secret_type: The type of single sign on Secret Type. Known values are: "SharedKey", + "Certificate", "SharedKeyInKeyVault", and "CertificateInKeyVault". + :vartype sso_secret_type: str or ~azure.mgmt.desktopvirtualization.models.SSOSecretType + :ivar preferred_app_group_type: The type of preferred application group type, default to + Desktop Application Group. Required. Known values are: "None", "Desktop", and "RailApplications". - :type preferred_app_group_type: str or - ~desktop_virtualization_api_client.models.PreferredAppGroupType - :param start_vm_on_connect: The flag to turn on/off StartVMOnConnect feature. - :type start_vm_on_connect: bool - :param migration_request: The registration info of HostPool. - :type migration_request: ~desktop_virtualization_api_client.models.MigrationRequestProperties + :vartype preferred_app_group_type: str or + ~azure.mgmt.desktopvirtualization.models.PreferredAppGroupType + :ivar start_vm_on_connect: The flag to turn on/off StartVMOnConnect feature. + :vartype start_vm_on_connect: bool :ivar cloud_pc_resource: Is cloud pc resource. :vartype cloud_pc_resource: bool - :param public_network_access: Enabled allows this resource to be accessed from both public and - private networks, Disabled allows this resource to only be accessed via private endpoints. - Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~desktop_virtualization_api_client.models.PublicNetworkAccess + :ivar agent_update: The session host configuration for updating agent, monitoring agent, and + stack component. + :vartype agent_update: ~azure.mgmt.desktopvirtualization.models.AgentUpdateProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'host_pool_type': {'required': True}, - 'load_balancer_type': {'required': True}, - 'application_group_references': {'readonly': True}, - 'preferred_app_group_type': {'required': True}, - 'cloud_pc_resource': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'host_pool_type': {'key': 'properties.hostPoolType', 'type': 'str'}, - 'personal_desktop_assignment_type': {'key': 'properties.personalDesktopAssignmentType', 'type': 'str'}, - 'custom_rdp_property': {'key': 'properties.customRdpProperty', 'type': 'str'}, - 'max_session_limit': {'key': 'properties.maxSessionLimit', 'type': 'int'}, - 'load_balancer_type': {'key': 'properties.loadBalancerType', 'type': 'str'}, - 'ring': {'key': 'properties.ring', 'type': 'int'}, - 'validation_environment': {'key': 'properties.validationEnvironment', 'type': 'bool'}, - 'registration_info': {'key': 'properties.registrationInfo', 'type': 'RegistrationInfo'}, - 'vm_template': {'key': 'properties.vmTemplate', 'type': 'str'}, - 'application_group_references': {'key': 'properties.applicationGroupReferences', 'type': '[str]'}, - 'ssoadfs_authority': {'key': 'properties.ssoadfsAuthority', 'type': 'str'}, - 'sso_client_id': {'key': 'properties.ssoClientId', 'type': 'str'}, - 'sso_client_secret_key_vault_path': {'key': 'properties.ssoClientSecretKeyVaultPath', 'type': 'str'}, - 'sso_secret_type': {'key': 'properties.ssoSecretType', 'type': 'str'}, - 'preferred_app_group_type': {'key': 'properties.preferredAppGroupType', 'type': 'str'}, - 'start_vm_on_connect': {'key': 'properties.startVMOnConnect', 'type': 'bool'}, - 'migration_request': {'key': 'properties.migrationRequest', 'type': 'MigrationRequestProperties'}, - 'cloud_pc_resource': {'key': 'properties.cloudPcResource', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "object_id": {"readonly": True}, + "host_pool_type": {"required": True}, + "load_balancer_type": {"required": True}, + "application_group_references": {"readonly": True}, + "preferred_app_group_type": {"required": True}, + "cloud_pc_resource": {"readonly": True}, } - def __init__( + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceModelWithAllowedPropertySetIdentity"}, + "sku": {"key": "sku", "type": "ResourceModelWithAllowedPropertySetSku"}, + "plan": {"key": "plan", "type": "ResourceModelWithAllowedPropertySetPlan"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "host_pool_type": {"key": "properties.hostPoolType", "type": "str"}, + "personal_desktop_assignment_type": {"key": "properties.personalDesktopAssignmentType", "type": "str"}, + "custom_rdp_property": {"key": "properties.customRdpProperty", "type": "str"}, + "max_session_limit": {"key": "properties.maxSessionLimit", "type": "int"}, + "load_balancer_type": {"key": "properties.loadBalancerType", "type": "str"}, + "ring": {"key": "properties.ring", "type": "int"}, + "validation_environment": {"key": "properties.validationEnvironment", "type": "bool"}, + "registration_info": {"key": "properties.registrationInfo", "type": "RegistrationInfo"}, + "vm_template": {"key": "properties.vmTemplate", "type": "str"}, + "application_group_references": {"key": "properties.applicationGroupReferences", "type": "[str]"}, + "ssoadfs_authority": {"key": "properties.ssoadfsAuthority", "type": "str"}, + "sso_client_id": {"key": "properties.ssoClientId", "type": "str"}, + "sso_client_secret_key_vault_path": {"key": "properties.ssoClientSecretKeyVaultPath", "type": "str"}, + "sso_secret_type": {"key": "properties.ssoSecretType", "type": "str"}, + "preferred_app_group_type": {"key": "properties.preferredAppGroupType", "type": "str"}, + "start_vm_on_connect": {"key": "properties.startVMOnConnect", "type": "bool"}, + "cloud_pc_resource": {"key": "properties.cloudPcResource", "type": "bool"}, + "agent_update": {"key": "properties.agentUpdate", "type": "AgentUpdateProperties"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, - host_pool_type: Union[str, "HostPoolType"], - load_balancer_type: Union[str, "LoadBalancerType"], - preferred_app_group_type: Union[str, "PreferredAppGroupType"], + host_pool_type: Union[str, "_models.HostPoolType"], + load_balancer_type: Union[str, "_models.LoadBalancerType"], + preferred_app_group_type: Union[str, "_models.PreferredAppGroupType"], location: Optional[str] = None, managed_by: Optional[str] = None, kind: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceModelWithAllowedPropertySetIdentity"] = None, - sku: Optional["ResourceModelWithAllowedPropertySetSku"] = None, - plan: Optional["ResourceModelWithAllowedPropertySetPlan"] = None, + identity: Optional["_models.ResourceModelWithAllowedPropertySetIdentity"] = None, + sku: Optional["_models.ResourceModelWithAllowedPropertySetSku"] = None, + plan: Optional["_models.ResourceModelWithAllowedPropertySetPlan"] = None, friendly_name: Optional[str] = None, description: Optional[str] = None, - personal_desktop_assignment_type: Optional[Union[str, "PersonalDesktopAssignmentType"]] = None, + personal_desktop_assignment_type: Optional[Union[str, "_models.PersonalDesktopAssignmentType"]] = None, custom_rdp_property: Optional[str] = None, max_session_limit: Optional[int] = None, ring: Optional[int] = None, validation_environment: Optional[bool] = None, - registration_info: Optional["RegistrationInfo"] = None, + registration_info: Optional["_models.RegistrationInfo"] = None, vm_template: Optional[str] = None, ssoadfs_authority: Optional[str] = None, sso_client_id: Optional[str] = None, sso_client_secret_key_vault_path: Optional[str] = None, - sso_secret_type: Optional[Union[str, "SSOSecretType"]] = None, + sso_secret_type: Optional[Union[str, "_models.SSOSecretType"]] = None, start_vm_on_connect: Optional[bool] = None, - migration_request: Optional["MigrationRequestProperties"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + agent_update: Optional["_models.AgentUpdateProperties"] = None, **kwargs ): - super(HostPool, self).__init__(location=location, managed_by=managed_by, kind=kind, tags=tags, identity=identity, sku=sku, plan=plan, **kwargs) + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword managed_by: The fully qualified resource ID of the resource that manages this + resource. Indicates if this resource is managed by another Azure resource. If this is present, + complete mode deployment will not delete the resource if it is removed from the template since + it is managed by another resource. + :paramtype managed_by: str + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: + :paramtype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :keyword sku: + :paramtype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :keyword plan: + :paramtype plan: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan + :keyword friendly_name: Friendly name of HostPool. + :paramtype friendly_name: str + :keyword description: Description of HostPool. + :paramtype description: str + :keyword host_pool_type: HostPool type for desktop. Required. Known values are: "Personal", + "Pooled", and "BYODesktop". + :paramtype host_pool_type: str or ~azure.mgmt.desktopvirtualization.models.HostPoolType + :keyword personal_desktop_assignment_type: PersonalDesktopAssignment type for HostPool. Known + values are: "Automatic" and "Direct". + :paramtype personal_desktop_assignment_type: str or + ~azure.mgmt.desktopvirtualization.models.PersonalDesktopAssignmentType + :keyword custom_rdp_property: Custom rdp property of HostPool. + :paramtype custom_rdp_property: str + :keyword max_session_limit: The max session limit of HostPool. + :paramtype max_session_limit: int + :keyword load_balancer_type: The type of the load balancer. Required. Known values are: + "BreadthFirst", "DepthFirst", and "Persistent". + :paramtype load_balancer_type: str or ~azure.mgmt.desktopvirtualization.models.LoadBalancerType + :keyword ring: The ring number of HostPool. + :paramtype ring: int + :keyword validation_environment: Is validation environment. + :paramtype validation_environment: bool + :keyword registration_info: The registration info of HostPool. + :paramtype registration_info: ~azure.mgmt.desktopvirtualization.models.RegistrationInfo + :keyword vm_template: VM template for sessionhosts configuration within hostpool. + :paramtype vm_template: str + :keyword ssoadfs_authority: URL to customer ADFS server for signing WVD SSO certificates. + :paramtype ssoadfs_authority: str + :keyword sso_client_id: ClientId for the registered Relying Party used to issue WVD SSO + certificates. + :paramtype sso_client_id: str + :keyword sso_client_secret_key_vault_path: Path to Azure KeyVault storing the secret used for + communication to ADFS. + :paramtype sso_client_secret_key_vault_path: str + :keyword sso_secret_type: The type of single sign on Secret Type. Known values are: + "SharedKey", "Certificate", "SharedKeyInKeyVault", and "CertificateInKeyVault". + :paramtype sso_secret_type: str or ~azure.mgmt.desktopvirtualization.models.SSOSecretType + :keyword preferred_app_group_type: The type of preferred application group type, default to + Desktop Application Group. Required. Known values are: "None", "Desktop", and + "RailApplications". + :paramtype preferred_app_group_type: str or + ~azure.mgmt.desktopvirtualization.models.PreferredAppGroupType + :keyword start_vm_on_connect: The flag to turn on/off StartVMOnConnect feature. + :paramtype start_vm_on_connect: bool + :keyword agent_update: The session host configuration for updating agent, monitoring agent, and + stack component. + :paramtype agent_update: ~azure.mgmt.desktopvirtualization.models.AgentUpdateProperties + """ + super().__init__( + location=location, + managed_by=managed_by, + kind=kind, + tags=tags, + identity=identity, + sku=sku, + plan=plan, + **kwargs + ) self.system_data = None self.object_id = None self.friendly_name = friendly_name @@ -1073,43 +1436,41 @@ def __init__( self.sso_secret_type = sso_secret_type self.preferred_app_group_type = preferred_app_group_type self.start_vm_on_connect = start_vm_on_connect - self.migration_request = migration_request self.cloud_pc_resource = None - self.public_network_access = public_network_access + self.agent_update = agent_update -class HostPoolList(msrest.serialization.Model): +class HostPoolList(_serialization.Model): """List of HostPool definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of HostPool definitions. - :type value: list[~desktop_virtualization_api_client.models.HostPool] + :ivar value: List of HostPool definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.HostPool] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[HostPool]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[HostPool]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["HostPool"]] = None, - **kwargs - ): - super(HostPoolList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.HostPool"]] = None, **kwargs): + """ + :keyword value: List of HostPool definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.HostPool] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class HostPoolPatch(Resource): +class HostPoolPatch(Resource): # pylint: disable=too-many-instance-attributes """HostPool properties that can be patched. Variables are only populated by the server, and will be ignored when sending a request. @@ -1122,82 +1483,81 @@ class HostPoolPatch(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param friendly_name: Friendly name of HostPool. - :type friendly_name: str - :param description: Description of HostPool. - :type description: str - :param custom_rdp_property: Custom rdp property of HostPool. - :type custom_rdp_property: str - :param max_session_limit: The max session limit of HostPool. - :type max_session_limit: int - :param personal_desktop_assignment_type: PersonalDesktopAssignment type for HostPool. Possible - values include: "Automatic", "Direct". - :type personal_desktop_assignment_type: str or - ~desktop_virtualization_api_client.models.PersonalDesktopAssignmentType - :param load_balancer_type: The type of the load balancer. Possible values include: - "BreadthFirst", "DepthFirst", "Persistent". - :type load_balancer_type: str or ~desktop_virtualization_api_client.models.LoadBalancerType - :param ring: The ring number of HostPool. - :type ring: int - :param validation_environment: Is validation environment. - :type validation_environment: bool - :param registration_info: The registration info of HostPool. - :type registration_info: ~desktop_virtualization_api_client.models.RegistrationInfoPatch - :param vm_template: VM template for sessionhosts configuration within hostpool. - :type vm_template: str - :param ssoadfs_authority: URL to customer ADFS server for signing WVD SSO certificates. - :type ssoadfs_authority: str - :param sso_client_id: ClientId for the registered Relying Party used to issue WVD SSO + :ivar tags: tags to be updated. + :vartype tags: dict[str, str] + :ivar friendly_name: Friendly name of HostPool. + :vartype friendly_name: str + :ivar description: Description of HostPool. + :vartype description: str + :ivar custom_rdp_property: Custom rdp property of HostPool. + :vartype custom_rdp_property: str + :ivar max_session_limit: The max session limit of HostPool. + :vartype max_session_limit: int + :ivar personal_desktop_assignment_type: PersonalDesktopAssignment type for HostPool. Known + values are: "Automatic" and "Direct". + :vartype personal_desktop_assignment_type: str or + ~azure.mgmt.desktopvirtualization.models.PersonalDesktopAssignmentType + :ivar load_balancer_type: The type of the load balancer. Known values are: "BreadthFirst", + "DepthFirst", and "Persistent". + :vartype load_balancer_type: str or ~azure.mgmt.desktopvirtualization.models.LoadBalancerType + :ivar ring: The ring number of HostPool. + :vartype ring: int + :ivar validation_environment: Is validation environment. + :vartype validation_environment: bool + :ivar registration_info: The registration info of HostPool. + :vartype registration_info: ~azure.mgmt.desktopvirtualization.models.RegistrationInfoPatch + :ivar vm_template: VM template for sessionhosts configuration within hostpool. + :vartype vm_template: str + :ivar ssoadfs_authority: URL to customer ADFS server for signing WVD SSO certificates. + :vartype ssoadfs_authority: str + :ivar sso_client_id: ClientId for the registered Relying Party used to issue WVD SSO certificates. - :type sso_client_id: str - :param sso_client_secret_key_vault_path: Path to Azure KeyVault storing the secret used for + :vartype sso_client_id: str + :ivar sso_client_secret_key_vault_path: Path to Azure KeyVault storing the secret used for communication to ADFS. - :type sso_client_secret_key_vault_path: str - :param sso_secret_type: The type of single sign on Secret Type. Possible values include: - "SharedKey", "Certificate", "SharedKeyInKeyVault", "CertificateInKeyVault". - :type sso_secret_type: str or ~desktop_virtualization_api_client.models.SSOSecretType - :param preferred_app_group_type: The type of preferred application group type, default to - Desktop Application Group. Possible values include: "None", "Desktop", "RailApplications". - :type preferred_app_group_type: str or - ~desktop_virtualization_api_client.models.PreferredAppGroupType - :param start_vm_on_connect: The flag to turn on/off StartVMOnConnect feature. - :type start_vm_on_connect: bool - :param public_network_access: Enabled to allow this resource to be access from the public - network. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~desktop_virtualization_api_client.models.PublicNetworkAccess + :vartype sso_client_secret_key_vault_path: str + :ivar sso_secret_type: The type of single sign on Secret Type. Known values are: "SharedKey", + "Certificate", "SharedKeyInKeyVault", and "CertificateInKeyVault". + :vartype sso_secret_type: str or ~azure.mgmt.desktopvirtualization.models.SSOSecretType + :ivar preferred_app_group_type: The type of preferred application group type, default to + Desktop Application Group. Known values are: "None", "Desktop", and "RailApplications". + :vartype preferred_app_group_type: str or + ~azure.mgmt.desktopvirtualization.models.PreferredAppGroupType + :ivar start_vm_on_connect: The flag to turn on/off StartVMOnConnect feature. + :vartype start_vm_on_connect: bool + :ivar agent_update: The session host configuration for updating agent, monitoring agent, and + stack component. + :vartype agent_update: ~azure.mgmt.desktopvirtualization.models.AgentUpdatePatchProperties """ _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'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'custom_rdp_property': {'key': 'properties.customRdpProperty', 'type': 'str'}, - 'max_session_limit': {'key': 'properties.maxSessionLimit', 'type': 'int'}, - 'personal_desktop_assignment_type': {'key': 'properties.personalDesktopAssignmentType', 'type': 'str'}, - 'load_balancer_type': {'key': 'properties.loadBalancerType', 'type': 'str'}, - 'ring': {'key': 'properties.ring', 'type': 'int'}, - 'validation_environment': {'key': 'properties.validationEnvironment', 'type': 'bool'}, - 'registration_info': {'key': 'properties.registrationInfo', 'type': 'RegistrationInfoPatch'}, - 'vm_template': {'key': 'properties.vmTemplate', 'type': 'str'}, - 'ssoadfs_authority': {'key': 'properties.ssoadfsAuthority', 'type': 'str'}, - 'sso_client_id': {'key': 'properties.ssoClientId', 'type': 'str'}, - 'sso_client_secret_key_vault_path': {'key': 'properties.ssoClientSecretKeyVaultPath', 'type': 'str'}, - 'sso_secret_type': {'key': 'properties.ssoSecretType', 'type': 'str'}, - 'preferred_app_group_type': {'key': 'properties.preferredAppGroupType', 'type': 'str'}, - 'start_vm_on_connect': {'key': 'properties.startVMOnConnect', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "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"}, + "tags": {"key": "tags", "type": "{str}"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "custom_rdp_property": {"key": "properties.customRdpProperty", "type": "str"}, + "max_session_limit": {"key": "properties.maxSessionLimit", "type": "int"}, + "personal_desktop_assignment_type": {"key": "properties.personalDesktopAssignmentType", "type": "str"}, + "load_balancer_type": {"key": "properties.loadBalancerType", "type": "str"}, + "ring": {"key": "properties.ring", "type": "int"}, + "validation_environment": {"key": "properties.validationEnvironment", "type": "bool"}, + "registration_info": {"key": "properties.registrationInfo", "type": "RegistrationInfoPatch"}, + "vm_template": {"key": "properties.vmTemplate", "type": "str"}, + "ssoadfs_authority": {"key": "properties.ssoadfsAuthority", "type": "str"}, + "sso_client_id": {"key": "properties.ssoClientId", "type": "str"}, + "sso_client_secret_key_vault_path": {"key": "properties.ssoClientSecretKeyVaultPath", "type": "str"}, + "sso_secret_type": {"key": "properties.ssoSecretType", "type": "str"}, + "preferred_app_group_type": {"key": "properties.preferredAppGroupType", "type": "str"}, + "start_vm_on_connect": {"key": "properties.startVMOnConnect", "type": "bool"}, + "agent_update": {"key": "properties.agentUpdate", "type": "AgentUpdatePatchProperties"}, } def __init__( @@ -1208,22 +1568,69 @@ def __init__( description: Optional[str] = None, custom_rdp_property: Optional[str] = None, max_session_limit: Optional[int] = None, - personal_desktop_assignment_type: Optional[Union[str, "PersonalDesktopAssignmentType"]] = None, - load_balancer_type: Optional[Union[str, "LoadBalancerType"]] = None, + personal_desktop_assignment_type: Optional[Union[str, "_models.PersonalDesktopAssignmentType"]] = None, + load_balancer_type: Optional[Union[str, "_models.LoadBalancerType"]] = None, ring: Optional[int] = None, validation_environment: Optional[bool] = None, - registration_info: Optional["RegistrationInfoPatch"] = None, + registration_info: Optional["_models.RegistrationInfoPatch"] = None, vm_template: Optional[str] = None, ssoadfs_authority: Optional[str] = None, sso_client_id: Optional[str] = None, sso_client_secret_key_vault_path: Optional[str] = None, - sso_secret_type: Optional[Union[str, "SSOSecretType"]] = None, - preferred_app_group_type: Optional[Union[str, "PreferredAppGroupType"]] = None, + sso_secret_type: Optional[Union[str, "_models.SSOSecretType"]] = None, + preferred_app_group_type: Optional[Union[str, "_models.PreferredAppGroupType"]] = None, start_vm_on_connect: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + agent_update: Optional["_models.AgentUpdatePatchProperties"] = None, **kwargs ): - super(HostPoolPatch, self).__init__(**kwargs) + """ + :keyword tags: tags to be updated. + :paramtype tags: dict[str, str] + :keyword friendly_name: Friendly name of HostPool. + :paramtype friendly_name: str + :keyword description: Description of HostPool. + :paramtype description: str + :keyword custom_rdp_property: Custom rdp property of HostPool. + :paramtype custom_rdp_property: str + :keyword max_session_limit: The max session limit of HostPool. + :paramtype max_session_limit: int + :keyword personal_desktop_assignment_type: PersonalDesktopAssignment type for HostPool. Known + values are: "Automatic" and "Direct". + :paramtype personal_desktop_assignment_type: str or + ~azure.mgmt.desktopvirtualization.models.PersonalDesktopAssignmentType + :keyword load_balancer_type: The type of the load balancer. Known values are: "BreadthFirst", + "DepthFirst", and "Persistent". + :paramtype load_balancer_type: str or ~azure.mgmt.desktopvirtualization.models.LoadBalancerType + :keyword ring: The ring number of HostPool. + :paramtype ring: int + :keyword validation_environment: Is validation environment. + :paramtype validation_environment: bool + :keyword registration_info: The registration info of HostPool. + :paramtype registration_info: ~azure.mgmt.desktopvirtualization.models.RegistrationInfoPatch + :keyword vm_template: VM template for sessionhosts configuration within hostpool. + :paramtype vm_template: str + :keyword ssoadfs_authority: URL to customer ADFS server for signing WVD SSO certificates. + :paramtype ssoadfs_authority: str + :keyword sso_client_id: ClientId for the registered Relying Party used to issue WVD SSO + certificates. + :paramtype sso_client_id: str + :keyword sso_client_secret_key_vault_path: Path to Azure KeyVault storing the secret used for + communication to ADFS. + :paramtype sso_client_secret_key_vault_path: str + :keyword sso_secret_type: The type of single sign on Secret Type. Known values are: + "SharedKey", "Certificate", "SharedKeyInKeyVault", and "CertificateInKeyVault". + :paramtype sso_secret_type: str or ~azure.mgmt.desktopvirtualization.models.SSOSecretType + :keyword preferred_app_group_type: The type of preferred application group type, default to + Desktop Application Group. Known values are: "None", "Desktop", and "RailApplications". + :paramtype preferred_app_group_type: str or + ~azure.mgmt.desktopvirtualization.models.PreferredAppGroupType + :keyword start_vm_on_connect: The flag to turn on/off StartVMOnConnect feature. + :paramtype start_vm_on_connect: bool + :keyword agent_update: The session host configuration for updating agent, monitoring agent, and + stack component. + :paramtype agent_update: ~azure.mgmt.desktopvirtualization.models.AgentUpdatePatchProperties + """ + super().__init__(**kwargs) self.tags = tags self.friendly_name = friendly_name self.description = description @@ -1241,10 +1648,10 @@ def __init__( self.sso_secret_type = sso_secret_type self.preferred_app_group_type = preferred_app_group_type self.start_vm_on_connect = start_vm_on_connect - self.public_network_access = public_network_access + self.agent_update = agent_update -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1253,49 +1660,47 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. - :type type: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): - super(Identity, self).__init__(**kwargs) + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs): + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. - :param name: Name of the log. - :type name: str - :param display_name: Localized friendly display name of the log. - :type display_name: str - :param blob_duration: Blob duration of the log. - :type blob_duration: str + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Localized friendly display name of the log. + :vartype display_name: str + :ivar blob_duration: Blob duration of the log. + :vartype blob_duration: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -1306,61 +1711,101 @@ def __init__( blob_duration: Optional[str] = None, **kwargs ): - super(LogSpecification, self).__init__(**kwargs) + """ + :keyword name: Name of the log. + :paramtype name: str + :keyword display_name: Localized friendly display name of the log. + :paramtype display_name: str + :keyword blob_duration: Blob duration of the log. + :paramtype blob_duration: str + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class MigrationRequestProperties(msrest.serialization.Model): - """Properties for arm migration. +class MaintenanceWindowPatchProperties(_serialization.Model): + """Maintenance window starting hour and day of week. - :param operation: The type of operation for migration. Possible values include: "Start", - "Revoke", "Complete", "Hide", "Unhide". - :type operation: str or ~desktop_virtualization_api_client.models.Operation - :param migration_path: The path to the legacy object to migrate. - :type migration_path: str + :ivar hour: The update start hour of the day. (0 - 23). + :vartype hour: int + :ivar day_of_week: Day of the week. Known values are: "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday", and "Sunday". + :vartype day_of_week: str or ~azure.mgmt.desktopvirtualization.models.DayOfWeek """ _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'migration_path': {'key': 'migrationPath', 'type': 'str'}, + "hour": {"key": "hour", "type": "int"}, + "day_of_week": {"key": "dayOfWeek", "type": "str"}, } def __init__( - self, - *, - operation: Optional[Union[str, "Operation"]] = None, - migration_path: Optional[str] = None, - **kwargs + self, *, hour: Optional[int] = None, day_of_week: Optional[Union[str, "_models.DayOfWeek"]] = None, **kwargs ): - super(MigrationRequestProperties, self).__init__(**kwargs) - self.operation = operation - self.migration_path = migration_path + """ + :keyword hour: The update start hour of the day. (0 - 23). + :paramtype hour: int + :keyword day_of_week: Day of the week. Known values are: "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday", and "Sunday". + :paramtype day_of_week: str or ~azure.mgmt.desktopvirtualization.models.DayOfWeek + """ + super().__init__(**kwargs) + self.hour = hour + self.day_of_week = day_of_week -class MSIXImageURI(msrest.serialization.Model): - """Represents URI referring to MSIX Image. +class MaintenanceWindowProperties(_serialization.Model): + """Maintenance window starting hour and day of week. - :param uri: URI to Image. - :type uri: str + :ivar hour: The update start hour of the day. (0 - 23). + :vartype hour: int + :ivar day_of_week: Day of the week. Known values are: "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday", and "Sunday". + :vartype day_of_week: str or ~azure.mgmt.desktopvirtualization.models.DayOfWeek """ _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, + "hour": {"key": "hour", "type": "int"}, + "day_of_week": {"key": "dayOfWeek", "type": "str"}, } def __init__( - self, - *, - uri: Optional[str] = None, - **kwargs + self, *, hour: Optional[int] = None, day_of_week: Optional[Union[str, "_models.DayOfWeek"]] = None, **kwargs ): - super(MSIXImageURI, self).__init__(**kwargs) + """ + :keyword hour: The update start hour of the day. (0 - 23). + :paramtype hour: int + :keyword day_of_week: Day of the week. Known values are: "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday", and "Sunday". + :paramtype day_of_week: str or ~azure.mgmt.desktopvirtualization.models.DayOfWeek + """ + super().__init__(**kwargs) + self.hour = hour + self.day_of_week = day_of_week + + +class MSIXImageURI(_serialization.Model): + """Represents URI referring to MSIX Image. + + :ivar uri: URI to Image. + :vartype uri: str + """ + + _attribute_map = { + "uri": {"key": "uri", "type": "str"}, + } + + def __init__(self, *, uri: Optional[str] = None, **kwargs): + """ + :keyword uri: URI to Image. + :paramtype uri: str + """ + super().__init__(**kwargs) self.uri = uri -class MSIXPackage(Resource): +class MSIXPackage(Resource): # pylint: disable=too-many-instance-attributes """Schema for MSIX Package properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1374,57 +1819,57 @@ class MSIXPackage(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - :param image_path: VHD/CIM image path on Network Share. - :type image_path: str - :param package_name: Package Name from appxmanifest.xml. - :type package_name: str - :param package_family_name: Package Family Name from appxmanifest.xml. Contains Package Name - and Publisher name. - :type package_family_name: str - :param display_name: User friendly Name to be displayed in the portal. - :type display_name: str - :param package_relative_path: Relative Path to the package inside the image. - :type package_relative_path: str - :param is_regular_registration: Specifies how to register Package in feed. - :type is_regular_registration: bool - :param is_active: Make this version of the package the active one across the hostpool. - :type is_active: bool - :param package_dependencies: List of package dependencies. - :type package_dependencies: - list[~desktop_virtualization_api_client.models.MsixPackageDependencies] - :param version: Package Version found in the appxmanifest.xml. - :type version: str - :param last_updated: Date Package was last updated, found in the appxmanifest.xml. - :type last_updated: ~datetime.datetime - :param package_applications: List of package applications. - :type package_applications: - list[~desktop_virtualization_api_client.models.MsixPackageApplications] + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData + :ivar image_path: VHD/CIM image path on Network Share. + :vartype image_path: str + :ivar package_name: Package Name from appxmanifest.xml. + :vartype package_name: str + :ivar package_family_name: Package Family Name from appxmanifest.xml. Contains Package Name and + Publisher name. + :vartype package_family_name: str + :ivar display_name: User friendly Name to be displayed in the portal. + :vartype display_name: str + :ivar package_relative_path: Relative Path to the package inside the image. + :vartype package_relative_path: str + :ivar is_regular_registration: Specifies how to register Package in feed. + :vartype is_regular_registration: bool + :ivar is_active: Make this version of the package the active one across the hostpool. + :vartype is_active: bool + :ivar package_dependencies: List of package dependencies. + :vartype package_dependencies: + list[~azure.mgmt.desktopvirtualization.models.MsixPackageDependencies] + :ivar version: Package Version found in the appxmanifest.xml. + :vartype version: str + :ivar last_updated: Date Package was last updated, found in the appxmanifest.xml. + :vartype last_updated: ~datetime.datetime + :ivar package_applications: List of package applications. + :vartype package_applications: + list[~azure.mgmt.desktopvirtualization.models.MsixPackageApplications] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'image_path': {'key': 'properties.imagePath', 'type': 'str'}, - 'package_name': {'key': 'properties.packageName', 'type': 'str'}, - 'package_family_name': {'key': 'properties.packageFamilyName', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'package_relative_path': {'key': 'properties.packageRelativePath', 'type': 'str'}, - 'is_regular_registration': {'key': 'properties.isRegularRegistration', 'type': 'bool'}, - 'is_active': {'key': 'properties.isActive', 'type': 'bool'}, - 'package_dependencies': {'key': 'properties.packageDependencies', 'type': '[MsixPackageDependencies]'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'last_updated': {'key': 'properties.lastUpdated', 'type': 'iso-8601'}, - 'package_applications': {'key': 'properties.packageApplications', 'type': '[MsixPackageApplications]'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "image_path": {"key": "properties.imagePath", "type": "str"}, + "package_name": {"key": "properties.packageName", "type": "str"}, + "package_family_name": {"key": "properties.packageFamilyName", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "package_relative_path": {"key": "properties.packageRelativePath", "type": "str"}, + "is_regular_registration": {"key": "properties.isRegularRegistration", "type": "bool"}, + "is_active": {"key": "properties.isActive", "type": "bool"}, + "package_dependencies": {"key": "properties.packageDependencies", "type": "[MsixPackageDependencies]"}, + "version": {"key": "properties.version", "type": "str"}, + "last_updated": {"key": "properties.lastUpdated", "type": "iso-8601"}, + "package_applications": {"key": "properties.packageApplications", "type": "[MsixPackageApplications]"}, } def __init__( @@ -1437,13 +1882,40 @@ def __init__( package_relative_path: Optional[str] = None, is_regular_registration: Optional[bool] = None, is_active: Optional[bool] = None, - package_dependencies: Optional[List["MsixPackageDependencies"]] = None, + package_dependencies: Optional[List["_models.MsixPackageDependencies"]] = None, version: Optional[str] = None, last_updated: Optional[datetime.datetime] = None, - package_applications: Optional[List["MsixPackageApplications"]] = None, + package_applications: Optional[List["_models.MsixPackageApplications"]] = None, **kwargs ): - super(MSIXPackage, self).__init__(**kwargs) + """ + :keyword image_path: VHD/CIM image path on Network Share. + :paramtype image_path: str + :keyword package_name: Package Name from appxmanifest.xml. + :paramtype package_name: str + :keyword package_family_name: Package Family Name from appxmanifest.xml. Contains Package Name + and Publisher name. + :paramtype package_family_name: str + :keyword display_name: User friendly Name to be displayed in the portal. + :paramtype display_name: str + :keyword package_relative_path: Relative Path to the package inside the image. + :paramtype package_relative_path: str + :keyword is_regular_registration: Specifies how to register Package in feed. + :paramtype is_regular_registration: bool + :keyword is_active: Make this version of the package the active one across the hostpool. + :paramtype is_active: bool + :keyword package_dependencies: List of package dependencies. + :paramtype package_dependencies: + list[~azure.mgmt.desktopvirtualization.models.MsixPackageDependencies] + :keyword version: Package Version found in the appxmanifest.xml. + :paramtype version: str + :keyword last_updated: Date Package was last updated, found in the appxmanifest.xml. + :paramtype last_updated: ~datetime.datetime + :keyword package_applications: List of package applications. + :paramtype package_applications: + list[~azure.mgmt.desktopvirtualization.models.MsixPackageApplications] + """ + super().__init__(**kwargs) self.system_data = None self.image_path = image_path self.package_name = package_name @@ -1458,34 +1930,34 @@ def __init__( self.package_applications = package_applications -class MsixPackageApplications(msrest.serialization.Model): +class MsixPackageApplications(_serialization.Model): """Schema for MSIX Package Application properties. - :param app_id: Package Application Id, found in appxmanifest.xml. - :type app_id: str - :param description: Description of Package Application. - :type description: str - :param app_user_model_id: Used to activate Package Application. Consists of Package Name and + :ivar app_id: Package Application Id, found in appxmanifest.xml. + :vartype app_id: str + :ivar description: Description of Package Application. + :vartype description: str + :ivar app_user_model_id: Used to activate Package Application. Consists of Package Name and ApplicationID. Found in appxmanifest.xml. - :type app_user_model_id: str - :param friendly_name: User friendly name. - :type friendly_name: str - :param icon_image_name: User friendly name. - :type icon_image_name: str - :param raw_icon: the icon a 64 bit string as a byte array. - :type raw_icon: bytearray - :param raw_png: the icon a 64 bit string as a byte array. - :type raw_png: bytearray + :vartype app_user_model_id: str + :ivar friendly_name: User friendly name. + :vartype friendly_name: str + :ivar icon_image_name: User friendly name. + :vartype icon_image_name: str + :ivar raw_icon: the icon a 64 bit string as a byte array. + :vartype raw_icon: bytes + :ivar raw_png: the icon a 64 bit string as a byte array. + :vartype raw_png: bytes """ _attribute_map = { - 'app_id': {'key': 'appId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'app_user_model_id': {'key': 'appUserModelID', 'type': 'str'}, - 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, - 'icon_image_name': {'key': 'iconImageName', 'type': 'str'}, - 'raw_icon': {'key': 'rawIcon', 'type': 'bytearray'}, - 'raw_png': {'key': 'rawPng', 'type': 'bytearray'}, + "app_id": {"key": "appId", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "app_user_model_id": {"key": "appUserModelID", "type": "str"}, + "friendly_name": {"key": "friendlyName", "type": "str"}, + "icon_image_name": {"key": "iconImageName", "type": "str"}, + "raw_icon": {"key": "rawIcon", "type": "bytearray"}, + "raw_png": {"key": "rawPng", "type": "bytearray"}, } def __init__( @@ -1496,11 +1968,28 @@ def __init__( app_user_model_id: Optional[str] = None, friendly_name: Optional[str] = None, icon_image_name: Optional[str] = None, - raw_icon: Optional[bytearray] = None, - raw_png: Optional[bytearray] = None, + raw_icon: Optional[bytes] = None, + raw_png: Optional[bytes] = None, **kwargs ): - super(MsixPackageApplications, self).__init__(**kwargs) + """ + :keyword app_id: Package Application Id, found in appxmanifest.xml. + :paramtype app_id: str + :keyword description: Description of Package Application. + :paramtype description: str + :keyword app_user_model_id: Used to activate Package Application. Consists of Package Name and + ApplicationID. Found in appxmanifest.xml. + :paramtype app_user_model_id: str + :keyword friendly_name: User friendly name. + :paramtype friendly_name: str + :keyword icon_image_name: User friendly name. + :paramtype icon_image_name: str + :keyword raw_icon: the icon a 64 bit string as a byte array. + :paramtype raw_icon: bytes + :keyword raw_png: the icon a 64 bit string as a byte array. + :paramtype raw_png: bytes + """ + super().__init__(**kwargs) self.app_id = app_id self.description = description self.app_user_model_id = app_user_model_id @@ -1510,21 +1999,21 @@ def __init__( self.raw_png = raw_png -class MsixPackageDependencies(msrest.serialization.Model): +class MsixPackageDependencies(_serialization.Model): """Schema for MSIX Package Dependencies properties. - :param dependency_name: Name of package dependency. - :type dependency_name: str - :param publisher: Name of dependency publisher. - :type publisher: str - :param min_version: Dependency version required. - :type min_version: str + :ivar dependency_name: Name of package dependency. + :vartype dependency_name: str + :ivar publisher: Name of dependency publisher. + :vartype publisher: str + :ivar min_version: Dependency version required. + :vartype min_version: str """ _attribute_map = { - 'dependency_name': {'key': 'dependencyName', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'min_version': {'key': 'minVersion', 'type': 'str'}, + "dependency_name": {"key": "dependencyName", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "min_version": {"key": "minVersion", "type": "str"}, } def __init__( @@ -1535,39 +2024,46 @@ def __init__( min_version: Optional[str] = None, **kwargs ): - super(MsixPackageDependencies, self).__init__(**kwargs) + """ + :keyword dependency_name: Name of package dependency. + :paramtype dependency_name: str + :keyword publisher: Name of dependency publisher. + :paramtype publisher: str + :keyword min_version: Dependency version required. + :paramtype min_version: str + """ + super().__init__(**kwargs) self.dependency_name = dependency_name self.publisher = publisher self.min_version = min_version -class MSIXPackageList(msrest.serialization.Model): +class MSIXPackageList(_serialization.Model): """List of MSIX Package definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of MSIX Package definitions. - :type value: list[~desktop_virtualization_api_client.models.MSIXPackage] + :ivar value: List of MSIX Package definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.MSIXPackage] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MSIXPackage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MSIXPackage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["MSIXPackage"]] = None, - **kwargs - ): - super(MSIXPackageList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.MSIXPackage"]] = None, **kwargs): + """ + :keyword value: List of MSIX Package definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.MSIXPackage] + """ + super().__init__(**kwargs) self.value = value self.next_link = None @@ -1585,27 +2081,27 @@ class MSIXPackagePatch(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param is_active: Set a version of the package to be active across hostpool. - :type is_active: bool - :param is_regular_registration: Set Registration mode. Regular or Delayed. - :type is_regular_registration: bool - :param display_name: Display name for MSIX Package. - :type display_name: str + :ivar is_active: Set a version of the package to be active across hostpool. + :vartype is_active: bool + :ivar is_regular_registration: Set Registration mode. Regular or Delayed. + :vartype is_regular_registration: bool + :ivar display_name: Display name for MSIX Package. + :vartype display_name: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, - 'is_active': {'key': 'properties.isActive', 'type': 'bool'}, - 'is_regular_registration': {'key': 'properties.isRegularRegistration', 'type': 'bool'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "is_active": {"key": "properties.isActive", "type": "bool"}, + "is_regular_registration": {"key": "properties.isRegularRegistration", "type": "bool"}, + "display_name": {"key": "properties.displayName", "type": "str"}, } def __init__( @@ -1616,65 +2112,72 @@ def __init__( display_name: Optional[str] = None, **kwargs ): - super(MSIXPackagePatch, self).__init__(**kwargs) + """ + :keyword is_active: Set a version of the package to be active across hostpool. + :paramtype is_active: bool + :keyword is_regular_registration: Set Registration mode. Regular or Delayed. + :paramtype is_regular_registration: bool + :keyword display_name: Display name for MSIX Package. + :paramtype display_name: str + """ + super().__init__(**kwargs) self.is_active = is_active self.is_regular_registration = is_regular_registration self.display_name = display_name -class OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Properties of the operation. - :param service_specification: Service specification payload. - :type service_specification: ~desktop_virtualization_api_client.models.ServiceSpecification + :ivar service_specification: Service specification payload. + :vartype service_specification: ~azure.mgmt.desktopvirtualization.models.ServiceSpecification """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): - super(OperationProperties, self).__init__(**kwargs) + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): + """ + :keyword service_specification: Service specification payload. + :paramtype service_specification: ~azure.mgmt.desktopvirtualization.models.ServiceSpecification + """ + super().__init__(**kwargs) self.service_specification = service_specification -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. All required parameters must be populated in order to send to Azure. - :param name: Required. A user defined name of the 3rd Party Artifact that is being procured. - :type name: str - :param publisher: Required. The publisher of the 3rd Party Artifact that is being bought. E.g. - NewRelic. - :type publisher: str - :param product: Required. The 3rd Party artifact that is being procured. E.g. NewRelic. Product - maps to the OfferID specified for the artifact at the time of Data Market onboarding. - :type product: str - :param promotion_code: A publisher provided promotion code as provisioned in Data Market for - the said product/artifact. - :type promotion_code: str - :param version: The version of the desired product/artifact. - :type version: str + :ivar name: A user defined name of the 3rd Party Artifact that is being procured. Required. + :vartype name: str + :ivar publisher: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. + Required. + :vartype publisher: str + :ivar product: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to + the OfferID specified for the artifact at the time of Data Market onboarding. Required. + :vartype product: str + :ivar promotion_code: A publisher provided promotion code as provisioned in Data Market for the + said product/artifact. + :vartype promotion_code: str + :ivar version: The version of the desired product/artifact. + :vartype version: str """ _validation = { - 'name': {'required': True}, - 'publisher': {'required': True}, - 'product': {'required': True}, + "name": {"required": True}, + "publisher": {"required": True}, + "product": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1687,7 +2190,22 @@ def __init__( version: Optional[str] = None, **kwargs ): - super(Plan, self).__init__(**kwargs) + """ + :keyword name: A user defined name of the 3rd Party Artifact that is being procured. Required. + :paramtype name: str + :keyword publisher: The publisher of the 3rd Party Artifact that is being bought. E.g. + NewRelic. Required. + :paramtype publisher: str + :keyword product: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to + the OfferID specified for the artifact at the time of Data Market onboarding. Required. + :paramtype product: str + :keyword promotion_code: A publisher provided promotion code as provisioned in Data Market for + the said product/artifact. + :paramtype promotion_code: str + :keyword version: The version of the desired product/artifact. + :paramtype version: str + """ + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1695,305 +2213,23 @@ def __init__( self.version = version -class PrivateEndpoint(msrest.serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(Resource): - """The Private Endpoint Connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param private_endpoint: The resource of private end point. - :type private_endpoint: ~desktop_virtualization_api_client.models.PrivateEndpoint - :param private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :type private_link_service_connection_state: - ~desktop_virtualization_api_client.models.PrivateLinkServiceConnectionState - :param provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". - :type provisioning_state: str or - ~desktop_virtualization_api_client.models.PrivateEndpointConnectionProvisioningState - """ - - _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'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, - provisioning_state: Optional[Union[str, "PrivateEndpointConnectionProvisioningState"]] = None, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = provisioning_state - - -class PrivateEndpointConnectionListResultWithSystemData(msrest.serialization.Model): - """List of private endpoint connection associated with the specified storage account. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Array of private endpoint connections. - :type value: - list[~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnectionWithSystemData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: Optional[List["PrivateEndpointConnectionWithSystemData"]] = None, - **kwargs - ): - super(PrivateEndpointConnectionListResultWithSystemData, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class PrivateEndpointConnectionWithSystemData(PrivateEndpointConnection): - """The Private Endpoint Connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param private_endpoint: The resource of private end point. - :type private_endpoint: ~desktop_virtualization_api_client.models.PrivateEndpoint - :param private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :type private_link_service_connection_state: - ~desktop_virtualization_api_client.models.PrivateLinkServiceConnectionState - :param provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". - :type provisioning_state: str or - ~desktop_virtualization_api_client.models.PrivateEndpointConnectionProvisioningState - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, - provisioning_state: Optional[Union[str, "PrivateEndpointConnectionProvisioningState"]] = None, - **kwargs - ): - super(PrivateEndpointConnectionWithSystemData, self).__init__(private_endpoint=private_endpoint, private_link_service_connection_state=private_link_service_connection_state, provisioning_state=provisioning_state, **kwargs) - self.system_data = None - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :param required_zone_names: The private link resource Private link DNS zone name. - :type required_zone_names: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(msrest.serialization.Model): - """A list of private link resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Array of private link resources. - :type value: list[~desktop_virtualization_api_client.models.PrivateLinkResource] - :ivar next_link: Link to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - **kwargs - ): - super(PrivateLinkResourceListResult, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """A collection of information about the state of the connection between service consumer and provider. - - :param status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". - :type status: str or - ~desktop_virtualization_api_client.models.PrivateEndpointServiceConnectionStatus - :param description: The reason for approval/rejection of the connection. - :type description: str - :param actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :type actions_required: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class RegistrationInfo(msrest.serialization.Model): +class RegistrationInfo(_serialization.Model): """Represents a RegistrationInfo definition. - :param expiration_time: Expiration time of registration token. - :type expiration_time: ~datetime.datetime - :param token: The registration token base64 encoded string. - :type token: str - :param registration_token_operation: The type of resetting the token. Possible values include: - "Delete", "None", "Update". - :type registration_token_operation: str or - ~desktop_virtualization_api_client.models.RegistrationTokenOperation + :ivar expiration_time: Expiration time of registration token. + :vartype expiration_time: ~datetime.datetime + :ivar token: The registration token base64 encoded string. + :vartype token: str + :ivar registration_token_operation: The type of resetting the token. Known values are: + "Delete", "None", and "Update". + :vartype registration_token_operation: str or + ~azure.mgmt.desktopvirtualization.models.RegistrationTokenOperation """ _attribute_map = { - 'expiration_time': {'key': 'expirationTime', 'type': 'iso-8601'}, - 'token': {'key': 'token', 'type': 'str'}, - 'registration_token_operation': {'key': 'registrationTokenOperation', 'type': 'str'}, + "expiration_time": {"key": "expirationTime", "type": "iso-8601"}, + "token": {"key": "token", "type": "str"}, + "registration_token_operation": {"key": "registrationTokenOperation", "type": "str"}, } def __init__( @@ -2001,39 +2237,57 @@ def __init__( *, expiration_time: Optional[datetime.datetime] = None, token: Optional[str] = None, - registration_token_operation: Optional[Union[str, "RegistrationTokenOperation"]] = None, + registration_token_operation: Optional[Union[str, "_models.RegistrationTokenOperation"]] = None, **kwargs ): - super(RegistrationInfo, self).__init__(**kwargs) + """ + :keyword expiration_time: Expiration time of registration token. + :paramtype expiration_time: ~datetime.datetime + :keyword token: The registration token base64 encoded string. + :paramtype token: str + :keyword registration_token_operation: The type of resetting the token. Known values are: + "Delete", "None", and "Update". + :paramtype registration_token_operation: str or + ~azure.mgmt.desktopvirtualization.models.RegistrationTokenOperation + """ + super().__init__(**kwargs) self.expiration_time = expiration_time self.token = token self.registration_token_operation = registration_token_operation -class RegistrationInfoPatch(msrest.serialization.Model): +class RegistrationInfoPatch(_serialization.Model): """Represents a RegistrationInfo definition. - :param expiration_time: Expiration time of registration token. - :type expiration_time: ~datetime.datetime - :param registration_token_operation: The type of resetting the token. Possible values include: - "Delete", "None", "Update". - :type registration_token_operation: str or - ~desktop_virtualization_api_client.models.RegistrationTokenOperation + :ivar expiration_time: Expiration time of registration token. + :vartype expiration_time: ~datetime.datetime + :ivar registration_token_operation: The type of resetting the token. Known values are: + "Delete", "None", and "Update". + :vartype registration_token_operation: str or + ~azure.mgmt.desktopvirtualization.models.RegistrationTokenOperation """ _attribute_map = { - 'expiration_time': {'key': 'expirationTime', 'type': 'iso-8601'}, - 'registration_token_operation': {'key': 'registrationTokenOperation', 'type': 'str'}, + "expiration_time": {"key": "expirationTime", "type": "iso-8601"}, + "registration_token_operation": {"key": "registrationTokenOperation", "type": "str"}, } def __init__( self, *, expiration_time: Optional[datetime.datetime] = None, - registration_token_operation: Optional[Union[str, "RegistrationTokenOperation"]] = None, + registration_token_operation: Optional[Union[str, "_models.RegistrationTokenOperation"]] = None, **kwargs ): - super(RegistrationInfoPatch, self).__init__(**kwargs) + """ + :keyword expiration_time: Expiration time of registration token. + :paramtype expiration_time: ~datetime.datetime + :keyword registration_token_operation: The type of resetting the token. Known values are: + "Delete", "None", and "Update". + :paramtype registration_token_operation: str or + ~azure.mgmt.desktopvirtualization.models.RegistrationTokenOperation + """ + super().__init__(**kwargs) self.expiration_time = expiration_time self.registration_token_operation = registration_token_operation @@ -2047,29 +2301,27 @@ class ResourceModelWithAllowedPropertySetIdentity(Identity): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. - :type type: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): - super(ResourceModelWithAllowedPropertySetIdentity, self).__init__(type=type, **kwargs) + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs): + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(type=type, **kwargs) class ResourceModelWithAllowedPropertySetPlan(Plan): @@ -2077,33 +2329,33 @@ class ResourceModelWithAllowedPropertySetPlan(Plan): All required parameters must be populated in order to send to Azure. - :param name: Required. A user defined name of the 3rd Party Artifact that is being procured. - :type name: str - :param publisher: Required. The publisher of the 3rd Party Artifact that is being bought. E.g. - NewRelic. - :type publisher: str - :param product: Required. The 3rd Party artifact that is being procured. E.g. NewRelic. Product - maps to the OfferID specified for the artifact at the time of Data Market onboarding. - :type product: str - :param promotion_code: A publisher provided promotion code as provisioned in Data Market for - the said product/artifact. - :type promotion_code: str - :param version: The version of the desired product/artifact. - :type version: str + :ivar name: A user defined name of the 3rd Party Artifact that is being procured. Required. + :vartype name: str + :ivar publisher: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. + Required. + :vartype publisher: str + :ivar product: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to + the OfferID specified for the artifact at the time of Data Market onboarding. Required. + :vartype product: str + :ivar promotion_code: A publisher provided promotion code as provisioned in Data Market for the + said product/artifact. + :vartype promotion_code: str + :ivar version: The version of the desired product/artifact. + :vartype version: str """ _validation = { - 'name': {'required': True}, - 'publisher': {'required': True}, - 'product': {'required': True}, + "name": {"required": True}, + "publisher": {"required": True}, + "product": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -2116,54 +2368,88 @@ def __init__( version: Optional[str] = None, **kwargs ): - super(ResourceModelWithAllowedPropertySetPlan, self).__init__(name=name, publisher=publisher, product=product, promotion_code=promotion_code, version=version, **kwargs) - - -class Sku(msrest.serialization.Model): + """ + :keyword name: A user defined name of the 3rd Party Artifact that is being procured. Required. + :paramtype name: str + :keyword publisher: The publisher of the 3rd Party Artifact that is being bought. E.g. + NewRelic. Required. + :paramtype publisher: str + :keyword product: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to + the OfferID specified for the artifact at the time of Data Market onboarding. Required. + :paramtype product: str + :keyword promotion_code: A publisher provided promotion code as provisioned in Data Market for + the said product/artifact. + :paramtype promotion_code: str + :keyword version: The version of the desired product/artifact. + :paramtype version: str + """ + super().__init__( + name=name, publisher=publisher, product=product, promotion_code=promotion_code, version=version, **kwargs + ) + + +class Sku(_serialization.Model): """The resource model definition representing SKU. All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. - :type name: str - :param 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". - :type tier: str or ~desktop_virtualization_api_client.models.SkuTier - :param size: The SKU size. When the name field is the combination of tier and some other value, + :ivar name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. + :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. Known values are: "Free", "Basic", + "Standard", and "Premium". + :vartype tier: str or ~azure.mgmt.desktopvirtualization.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. - :type size: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :param capacity: If the SKU supports scale out/in then the capacity integer should be included. + :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. - :type capacity: int + :vartype capacity: int """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - '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'}, + "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, *, name: str, - tier: Optional[Union[str, "SkuTier"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, size: Optional[str] = None, family: Optional[str] = None, capacity: Optional[int] = None, **kwargs ): - super(Sku, self).__init__(**kwargs) + """ + :keyword name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. + :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. Known values are: "Free", "Basic", + "Standard", and "Premium". + :paramtype tier: str or ~azure.mgmt.desktopvirtualization.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().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2176,102 +2462,129 @@ class ResourceModelWithAllowedPropertySetSku(Sku): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. - :type name: str - :param 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". - :type tier: str or ~desktop_virtualization_api_client.models.SkuTier - :param size: The SKU size. When the name field is the combination of tier and some other value, + :ivar name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. + :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. Known values are: "Free", "Basic", + "Standard", and "Premium". + :vartype tier: str or ~azure.mgmt.desktopvirtualization.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. - :type size: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :param capacity: If the SKU supports scale out/in then the capacity integer should be included. + :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. - :type capacity: int + :vartype capacity: int """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - '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'}, + "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, *, name: str, - tier: Optional[Union[str, "SkuTier"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, size: Optional[str] = None, family: Optional[str] = None, capacity: Optional[int] = None, **kwargs ): - super(ResourceModelWithAllowedPropertySetSku, self).__init__(name=name, tier=tier, size=size, family=family, capacity=capacity, **kwargs) - - -class ResourceProviderOperation(msrest.serialization.Model): + """ + :keyword name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. + :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. Known values are: "Free", "Basic", + "Standard", and "Premium". + :paramtype tier: str or ~azure.mgmt.desktopvirtualization.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().__init__(name=name, tier=tier, size=size, family=family, capacity=capacity, **kwargs) + + +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. - :param name: Operation name, in format of {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~desktop_virtualization_api_client.models.ResourceProviderOperationDisplay - :param is_data_action: Is a data action. - :type is_data_action: bool - :param properties: Properties of the operation. - :type properties: ~desktop_virtualization_api_client.models.OperationProperties + :ivar name: Operation name, in format of {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.desktopvirtualization.models.ResourceProviderOperationDisplay + :ivar is_data_action: Is a data action. + :vartype is_data_action: bool + :ivar properties: Properties of the operation. + :vartype properties: ~azure.mgmt.desktopvirtualization.models.OperationProperties """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, + display: Optional["_models.ResourceProviderOperationDisplay"] = None, is_data_action: Optional[bool] = None, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): - super(ResourceProviderOperation, self).__init__(**kwargs) + """ + :keyword name: Operation name, in format of {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.desktopvirtualization.models.ResourceProviderOperationDisplay + :keyword is_data_action: Is a data action. + :paramtype is_data_action: bool + :keyword properties: Properties of the operation. + :paramtype properties: ~azure.mgmt.desktopvirtualization.models.OperationProperties + """ + super().__init__(**kwargs) self.name = name self.display = display self.is_data_action = is_data_action self.properties = properties -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. - :param provider: Resource provider: Microsoft Desktop Virtualization. - :type provider: str - :param resource: Resource on which the operation is performed. - :type resource: str - :param operation: Type of operation: get, read, delete, etc. - :type operation: str - :param description: Description of this operation. - :type description: str + :ivar provider: Resource provider: Microsoft Desktop Virtualization. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of this operation. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2283,75 +2596,88 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Resource provider: Microsoft Desktop Virtualization. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of this operation. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of operations supported by this resource provider. - :type value: list[~desktop_virtualization_api_client.models.ResourceProviderOperation] + :ivar value: List of operations supported by this resource provider. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.ResourceProviderOperation] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): - super(ResourceProviderOperationList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs): + """ + :keyword value: List of operations supported by this resource provider. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.ResourceProviderOperation] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class ScalingHostPoolReference(msrest.serialization.Model): +class ScalingHostPoolReference(_serialization.Model): """Scaling plan reference to hostpool. - :param host_pool_arm_path: Arm path of referenced hostpool. - :type host_pool_arm_path: str - :param scaling_plan_enabled: Is the scaling plan enabled for this hostpool. - :type scaling_plan_enabled: bool + :ivar host_pool_arm_path: Arm path of referenced hostpool. + :vartype host_pool_arm_path: str + :ivar scaling_plan_enabled: Is the scaling plan enabled for this hostpool. + :vartype scaling_plan_enabled: bool """ _attribute_map = { - 'host_pool_arm_path': {'key': 'hostPoolArmPath', 'type': 'str'}, - 'scaling_plan_enabled': {'key': 'scalingPlanEnabled', 'type': 'bool'}, + "host_pool_arm_path": {"key": "hostPoolArmPath", "type": "str"}, + "scaling_plan_enabled": {"key": "scalingPlanEnabled", "type": "bool"}, } def __init__( - self, - *, - host_pool_arm_path: Optional[str] = None, - scaling_plan_enabled: Optional[bool] = None, - **kwargs + self, *, host_pool_arm_path: Optional[str] = None, scaling_plan_enabled: Optional[bool] = None, **kwargs ): - super(ScalingHostPoolReference, self).__init__(**kwargs) + """ + :keyword host_pool_arm_path: Arm path of referenced hostpool. + :paramtype host_pool_arm_path: str + :keyword scaling_plan_enabled: Is the scaling plan enabled for this hostpool. + :paramtype scaling_plan_enabled: bool + """ + super().__init__(**kwargs) self.host_pool_arm_path = host_pool_arm_path self.scaling_plan_enabled = scaling_plan_enabled -class ScalingPlan(ResourceModelWithAllowedPropertySet): +class ScalingPlan(ResourceModelWithAllowedPropertySet): # pylint: disable=too-many-instance-attributes """Represents a scaling plan definition. Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str @@ -2360,106 +2686,154 @@ class ScalingPlan(ResourceModelWithAllowedPropertySet): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar managed_by: The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :vartype managed_by: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar etag: The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: + :vartype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :ivar sku: + :vartype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :ivar plan: + :vartype plan: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData :ivar object_id: ObjectId of scaling plan. (internal use). :vartype object_id: str - :param description: Description of scaling plan. - :type description: str - :param friendly_name: User friendly name of scaling plan. - :type friendly_name: str - :param time_zone: Timezone of the scaling plan. - :type time_zone: str - :param host_pool_type: HostPool type for desktop. Possible values include: "Pooled". - :type host_pool_type: str or ~desktop_virtualization_api_client.models.ScalingHostPoolType - :param exclusion_tag: Exclusion tag for scaling plan. - :type exclusion_tag: str - :param schedules: List of ScalingSchedule definitions. - :type schedules: list[~desktop_virtualization_api_client.models.ScalingSchedule] - :param host_pool_references: List of ScalingHostPoolReference definitions. - :type host_pool_references: - list[~desktop_virtualization_api_client.models.ScalingHostPoolReference] + :ivar description: Description of scaling plan. + :vartype description: str + :ivar friendly_name: User friendly name of scaling plan. + :vartype friendly_name: str + :ivar time_zone: Timezone of the scaling plan. Required. + :vartype time_zone: str + :ivar host_pool_type: HostPool type for desktop. "Pooled" + :vartype host_pool_type: str or ~azure.mgmt.desktopvirtualization.models.ScalingHostPoolType + :ivar exclusion_tag: Exclusion tag for scaling plan. + :vartype exclusion_tag: str + :ivar schedules: List of ScalingPlanPooledSchedule definitions. + :vartype schedules: list[~azure.mgmt.desktopvirtualization.models.ScalingSchedule] + :ivar host_pool_references: List of ScalingHostPoolReference definitions. + :vartype host_pool_references: + list[~azure.mgmt.desktopvirtualization.models.ScalingHostPoolReference] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'host_pool_type': {'key': 'properties.hostPoolType', 'type': 'str'}, - 'exclusion_tag': {'key': 'properties.exclusionTag', 'type': 'str'}, - 'schedules': {'key': 'properties.schedules', 'type': '[ScalingSchedule]'}, - 'host_pool_references': {'key': 'properties.hostPoolReferences', 'type': '[ScalingHostPoolReference]'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "object_id": {"readonly": True}, + "time_zone": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceModelWithAllowedPropertySetIdentity"}, + "sku": {"key": "sku", "type": "ResourceModelWithAllowedPropertySetSku"}, + "plan": {"key": "plan", "type": "ResourceModelWithAllowedPropertySetPlan"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "host_pool_type": {"key": "properties.hostPoolType", "type": "str"}, + "exclusion_tag": {"key": "properties.exclusionTag", "type": "str"}, + "schedules": {"key": "properties.schedules", "type": "[ScalingSchedule]"}, + "host_pool_references": {"key": "properties.hostPoolReferences", "type": "[ScalingHostPoolReference]"}, } def __init__( self, *, + time_zone: str, location: Optional[str] = None, managed_by: Optional[str] = None, kind: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceModelWithAllowedPropertySetIdentity"] = None, - sku: Optional["ResourceModelWithAllowedPropertySetSku"] = None, - plan: Optional["ResourceModelWithAllowedPropertySetPlan"] = None, + identity: Optional["_models.ResourceModelWithAllowedPropertySetIdentity"] = None, + sku: Optional["_models.ResourceModelWithAllowedPropertySetSku"] = None, + plan: Optional["_models.ResourceModelWithAllowedPropertySetPlan"] = None, description: Optional[str] = None, friendly_name: Optional[str] = None, - time_zone: Optional[str] = None, - host_pool_type: Optional[Union[str, "ScalingHostPoolType"]] = None, + host_pool_type: Union[str, "_models.ScalingHostPoolType"] = "Pooled", exclusion_tag: Optional[str] = None, - schedules: Optional[List["ScalingSchedule"]] = None, - host_pool_references: Optional[List["ScalingHostPoolReference"]] = None, + schedules: Optional[List["_models.ScalingSchedule"]] = None, + host_pool_references: Optional[List["_models.ScalingHostPoolReference"]] = None, **kwargs ): - super(ScalingPlan, self).__init__(location=location, managed_by=managed_by, kind=kind, tags=tags, identity=identity, sku=sku, plan=plan, **kwargs) + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword managed_by: The fully qualified resource ID of the resource that manages this + resource. Indicates if this resource is managed by another Azure resource. If this is present, + complete mode deployment will not delete the resource if it is removed from the template since + it is managed by another resource. + :paramtype managed_by: str + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: + :paramtype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :keyword sku: + :paramtype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :keyword plan: + :paramtype plan: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan + :keyword description: Description of scaling plan. + :paramtype description: str + :keyword friendly_name: User friendly name of scaling plan. + :paramtype friendly_name: str + :keyword time_zone: Timezone of the scaling plan. Required. + :paramtype time_zone: str + :keyword host_pool_type: HostPool type for desktop. "Pooled" + :paramtype host_pool_type: str or ~azure.mgmt.desktopvirtualization.models.ScalingHostPoolType + :keyword exclusion_tag: Exclusion tag for scaling plan. + :paramtype exclusion_tag: str + :keyword schedules: List of ScalingPlanPooledSchedule definitions. + :paramtype schedules: list[~azure.mgmt.desktopvirtualization.models.ScalingSchedule] + :keyword host_pool_references: List of ScalingHostPoolReference definitions. + :paramtype host_pool_references: + list[~azure.mgmt.desktopvirtualization.models.ScalingHostPoolReference] + """ + super().__init__( + location=location, + managed_by=managed_by, + kind=kind, + tags=tags, + identity=identity, + sku=sku, + plan=plan, + **kwargs + ) self.system_data = None self.object_id = None self.description = description @@ -2471,65 +2845,64 @@ def __init__( self.host_pool_references = host_pool_references -class ScalingPlanList(msrest.serialization.Model): +class ScalingPlanList(_serialization.Model): """List of scaling plan definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of scaling plan definitions. - :type value: list[~desktop_virtualization_api_client.models.ScalingPlan] + :ivar value: List of scaling plan definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.ScalingPlan] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ScalingPlan]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScalingPlan]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ScalingPlan"]] = None, - **kwargs - ): - super(ScalingPlanList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.ScalingPlan"]] = None, **kwargs): + """ + :keyword value: List of scaling plan definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.ScalingPlan] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class ScalingPlanPatch(msrest.serialization.Model): +class ScalingPlanPatch(_serialization.Model): """Scaling plan properties that can be patched. - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of scaling plan. - :type description: str - :param friendly_name: User friendly name of scaling plan. - :type friendly_name: str - :param time_zone: Timezone of the scaling plan. - :type time_zone: str - :param exclusion_tag: Exclusion tag for scaling plan. - :type exclusion_tag: str - :param schedules: List of ScalingSchedule definitions. - :type schedules: list[~desktop_virtualization_api_client.models.ScalingSchedule] - :param host_pool_references: List of ScalingHostPoolReference definitions. - :type host_pool_references: - list[~desktop_virtualization_api_client.models.ScalingHostPoolReference] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'exclusion_tag': {'key': 'properties.exclusionTag', 'type': 'str'}, - 'schedules': {'key': 'properties.schedules', 'type': '[ScalingSchedule]'}, - 'host_pool_references': {'key': 'properties.hostPoolReferences', 'type': '[ScalingHostPoolReference]'}, + :ivar tags: tags to be updated. + :vartype tags: dict[str, str] + :ivar description: Description of scaling plan. + :vartype description: str + :ivar friendly_name: User friendly name of scaling plan. + :vartype friendly_name: str + :ivar time_zone: Timezone of the scaling plan. + :vartype time_zone: str + :ivar exclusion_tag: Exclusion tag for scaling plan. + :vartype exclusion_tag: str + :ivar schedules: List of ScalingSchedule definitions. + :vartype schedules: list[~azure.mgmt.desktopvirtualization.models.ScalingSchedule] + :ivar host_pool_references: List of ScalingHostPoolReference definitions. + :vartype host_pool_references: + list[~azure.mgmt.desktopvirtualization.models.ScalingHostPoolReference] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "exclusion_tag": {"key": "properties.exclusionTag", "type": "str"}, + "schedules": {"key": "properties.schedules", "type": "[ScalingSchedule]"}, + "host_pool_references": {"key": "properties.hostPoolReferences", "type": "[ScalingHostPoolReference]"}, } def __init__( @@ -2540,11 +2913,28 @@ def __init__( friendly_name: Optional[str] = None, time_zone: Optional[str] = None, exclusion_tag: Optional[str] = None, - schedules: Optional[List["ScalingSchedule"]] = None, - host_pool_references: Optional[List["ScalingHostPoolReference"]] = None, + schedules: Optional[List["_models.ScalingSchedule"]] = None, + host_pool_references: Optional[List["_models.ScalingHostPoolReference"]] = None, **kwargs ): - super(ScalingPlanPatch, self).__init__(**kwargs) + """ + :keyword tags: tags to be updated. + :paramtype tags: dict[str, str] + :keyword description: Description of scaling plan. + :paramtype description: str + :keyword friendly_name: User friendly name of scaling plan. + :paramtype friendly_name: str + :keyword time_zone: Timezone of the scaling plan. + :paramtype time_zone: str + :keyword exclusion_tag: Exclusion tag for scaling plan. + :paramtype exclusion_tag: str + :keyword schedules: List of ScalingSchedule definitions. + :paramtype schedules: list[~azure.mgmt.desktopvirtualization.models.ScalingSchedule] + :keyword host_pool_references: List of ScalingHostPoolReference definitions. + :paramtype host_pool_references: + list[~azure.mgmt.desktopvirtualization.models.ScalingHostPoolReference] + """ + super().__init__(**kwargs) self.tags = tags self.description = description self.friendly_name = friendly_name @@ -2554,111 +2944,175 @@ def __init__( self.host_pool_references = host_pool_references -class ScalingSchedule(msrest.serialization.Model): - """Scaling plan schedule. - - :param name: Name of the scaling schedule. - :type name: str - :param days_of_week: Set of days of the week on which this schedule is active. - :type days_of_week: list[str or - ~desktop_virtualization_api_client.models.ScalingScheduleDaysOfWeekItem] - :param ramp_up_start_time: Starting time for ramp up period. - :type ramp_up_start_time: ~desktop_virtualization_api_client.models.Time - :param ramp_up_load_balancing_algorithm: Load balancing algorithm for ramp up period. Possible - values include: "BreadthFirst", "DepthFirst". - :type ramp_up_load_balancing_algorithm: str or - ~desktop_virtualization_api_client.models.SessionHostLoadBalancingAlgorithm - :param ramp_up_minimum_hosts_pct: Minimum host percentage for ramp up period. - :type ramp_up_minimum_hosts_pct: int - :param ramp_up_capacity_threshold_pct: Capacity threshold for ramp up period. - :type ramp_up_capacity_threshold_pct: int - :param peak_start_time: Starting time for peak period. - :type peak_start_time: ~desktop_virtualization_api_client.models.Time - :param peak_load_balancing_algorithm: Load balancing algorithm for peak period. Possible values - include: "BreadthFirst", "DepthFirst". - :type peak_load_balancing_algorithm: str or - ~desktop_virtualization_api_client.models.SessionHostLoadBalancingAlgorithm - :param ramp_down_start_time: Starting time for ramp down period. - :type ramp_down_start_time: ~desktop_virtualization_api_client.models.Time - :param ramp_down_load_balancing_algorithm: Load balancing algorithm for ramp down period. - Possible values include: "BreadthFirst", "DepthFirst". - :type ramp_down_load_balancing_algorithm: str or - ~desktop_virtualization_api_client.models.SessionHostLoadBalancingAlgorithm - :param ramp_down_minimum_hosts_pct: Minimum host percentage for ramp down period. - :type ramp_down_minimum_hosts_pct: int - :param ramp_down_capacity_threshold_pct: Capacity threshold for ramp down period. - :type ramp_down_capacity_threshold_pct: int - :param ramp_down_force_logoff_users: Should users be logged off forcefully from hosts. - :type ramp_down_force_logoff_users: bool - :param ramp_down_stop_hosts_when: Specifies when to stop hosts during ramp down period. - Possible values include: "ZeroSessions", "ZeroActiveSessions". - :type ramp_down_stop_hosts_when: str or ~desktop_virtualization_api_client.models.StopHostsWhen - :param ramp_down_wait_time_minutes: Number of minutes to wait to stop hosts during ramp down +class ScalingPlanPooledSchedule(Resource): # pylint: disable=too-many-instance-attributes + """Represents a ScalingPlanPooledSchedule definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData + :ivar days_of_week: Set of days of the week on which this schedule is active. + :vartype days_of_week: list[str or ~azure.mgmt.desktopvirtualization.models.DayOfWeek] + :ivar ramp_up_start_time: Starting time for ramp up period. + :vartype ramp_up_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar ramp_up_load_balancing_algorithm: Load balancing algorithm for ramp up period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype ramp_up_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_up_minimum_hosts_pct: Minimum host percentage for ramp up period. + :vartype ramp_up_minimum_hosts_pct: int + :ivar ramp_up_capacity_threshold_pct: Capacity threshold for ramp up period. + :vartype ramp_up_capacity_threshold_pct: int + :ivar peak_start_time: Starting time for peak period. + :vartype peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar peak_load_balancing_algorithm: Load balancing algorithm for peak period. Known values + are: "BreadthFirst" and "DepthFirst". + :vartype peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_down_start_time: Starting time for ramp down period. + :vartype ramp_down_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar ramp_down_load_balancing_algorithm: Load balancing algorithm for ramp down period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype ramp_down_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_down_minimum_hosts_pct: Minimum host percentage for ramp down period. + :vartype ramp_down_minimum_hosts_pct: int + :ivar ramp_down_capacity_threshold_pct: Capacity threshold for ramp down period. + :vartype ramp_down_capacity_threshold_pct: int + :ivar ramp_down_force_logoff_users: Should users be logged off forcefully from hosts. + :vartype ramp_down_force_logoff_users: bool + :ivar ramp_down_stop_hosts_when: Specifies when to stop hosts during ramp down period. Known + values are: "ZeroSessions" and "ZeroActiveSessions". + :vartype ramp_down_stop_hosts_when: str or + ~azure.mgmt.desktopvirtualization.models.StopHostsWhen + :ivar ramp_down_wait_time_minutes: Number of minutes to wait to stop hosts during ramp down period. - :type ramp_down_wait_time_minutes: int - :param ramp_down_notification_message: Notification message for users during ramp down period. - :type ramp_down_notification_message: str - :param off_peak_start_time: Starting time for off-peak period. - :type off_peak_start_time: ~desktop_virtualization_api_client.models.Time - :param off_peak_load_balancing_algorithm: Load balancing algorithm for off-peak period. - Possible values include: "BreadthFirst", "DepthFirst". - :type off_peak_load_balancing_algorithm: str or - ~desktop_virtualization_api_client.models.SessionHostLoadBalancingAlgorithm + :vartype ramp_down_wait_time_minutes: int + :ivar ramp_down_notification_message: Notification message for users during ramp down period. + :vartype ramp_down_notification_message: str + :ivar off_peak_start_time: Starting time for off-peak period. + :vartype off_peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar off_peak_load_balancing_algorithm: Load balancing algorithm for off-peak period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype off_peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm """ _validation = { - 'ramp_up_minimum_hosts_pct': {'maximum': 100, 'minimum': 0}, - 'ramp_up_capacity_threshold_pct': {'maximum': 100, 'minimum': 1}, - 'ramp_down_minimum_hosts_pct': {'maximum': 100, 'minimum': 0}, - 'ramp_down_capacity_threshold_pct': {'maximum': 100, 'minimum': 0}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'days_of_week': {'key': 'daysOfWeek', 'type': '[str]'}, - 'ramp_up_start_time': {'key': 'rampUpStartTime', 'type': 'Time'}, - 'ramp_up_load_balancing_algorithm': {'key': 'rampUpLoadBalancingAlgorithm', 'type': 'str'}, - 'ramp_up_minimum_hosts_pct': {'key': 'rampUpMinimumHostsPct', 'type': 'int'}, - 'ramp_up_capacity_threshold_pct': {'key': 'rampUpCapacityThresholdPct', 'type': 'int'}, - 'peak_start_time': {'key': 'peakStartTime', 'type': 'Time'}, - 'peak_load_balancing_algorithm': {'key': 'peakLoadBalancingAlgorithm', 'type': 'str'}, - 'ramp_down_start_time': {'key': 'rampDownStartTime', 'type': 'Time'}, - 'ramp_down_load_balancing_algorithm': {'key': 'rampDownLoadBalancingAlgorithm', 'type': 'str'}, - 'ramp_down_minimum_hosts_pct': {'key': 'rampDownMinimumHostsPct', 'type': 'int'}, - 'ramp_down_capacity_threshold_pct': {'key': 'rampDownCapacityThresholdPct', 'type': 'int'}, - 'ramp_down_force_logoff_users': {'key': 'rampDownForceLogoffUsers', 'type': 'bool'}, - 'ramp_down_stop_hosts_when': {'key': 'rampDownStopHostsWhen', 'type': 'str'}, - 'ramp_down_wait_time_minutes': {'key': 'rampDownWaitTimeMinutes', 'type': 'int'}, - 'ramp_down_notification_message': {'key': 'rampDownNotificationMessage', 'type': 'str'}, - 'off_peak_start_time': {'key': 'offPeakStartTime', 'type': 'Time'}, - 'off_peak_load_balancing_algorithm': {'key': 'offPeakLoadBalancingAlgorithm', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "ramp_up_minimum_hosts_pct": {"maximum": 100, "minimum": 0}, + "ramp_up_capacity_threshold_pct": {"maximum": 100, "minimum": 1}, + "ramp_down_minimum_hosts_pct": {"maximum": 100, "minimum": 0}, + "ramp_down_capacity_threshold_pct": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "days_of_week": {"key": "properties.daysOfWeek", "type": "[str]"}, + "ramp_up_start_time": {"key": "properties.rampUpStartTime", "type": "Time"}, + "ramp_up_load_balancing_algorithm": {"key": "properties.rampUpLoadBalancingAlgorithm", "type": "str"}, + "ramp_up_minimum_hosts_pct": {"key": "properties.rampUpMinimumHostsPct", "type": "int"}, + "ramp_up_capacity_threshold_pct": {"key": "properties.rampUpCapacityThresholdPct", "type": "int"}, + "peak_start_time": {"key": "properties.peakStartTime", "type": "Time"}, + "peak_load_balancing_algorithm": {"key": "properties.peakLoadBalancingAlgorithm", "type": "str"}, + "ramp_down_start_time": {"key": "properties.rampDownStartTime", "type": "Time"}, + "ramp_down_load_balancing_algorithm": {"key": "properties.rampDownLoadBalancingAlgorithm", "type": "str"}, + "ramp_down_minimum_hosts_pct": {"key": "properties.rampDownMinimumHostsPct", "type": "int"}, + "ramp_down_capacity_threshold_pct": {"key": "properties.rampDownCapacityThresholdPct", "type": "int"}, + "ramp_down_force_logoff_users": {"key": "properties.rampDownForceLogoffUsers", "type": "bool"}, + "ramp_down_stop_hosts_when": {"key": "properties.rampDownStopHostsWhen", "type": "str"}, + "ramp_down_wait_time_minutes": {"key": "properties.rampDownWaitTimeMinutes", "type": "int"}, + "ramp_down_notification_message": {"key": "properties.rampDownNotificationMessage", "type": "str"}, + "off_peak_start_time": {"key": "properties.offPeakStartTime", "type": "Time"}, + "off_peak_load_balancing_algorithm": {"key": "properties.offPeakLoadBalancingAlgorithm", "type": "str"}, } def __init__( self, *, - name: Optional[str] = None, - days_of_week: Optional[List[Union[str, "ScalingScheduleDaysOfWeekItem"]]] = None, - ramp_up_start_time: Optional["Time"] = None, - ramp_up_load_balancing_algorithm: Optional[Union[str, "SessionHostLoadBalancingAlgorithm"]] = None, + days_of_week: Optional[List[Union[str, "_models.DayOfWeek"]]] = None, + ramp_up_start_time: Optional["_models.Time"] = None, + ramp_up_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, ramp_up_minimum_hosts_pct: Optional[int] = None, ramp_up_capacity_threshold_pct: Optional[int] = None, - peak_start_time: Optional["Time"] = None, - peak_load_balancing_algorithm: Optional[Union[str, "SessionHostLoadBalancingAlgorithm"]] = None, - ramp_down_start_time: Optional["Time"] = None, - ramp_down_load_balancing_algorithm: Optional[Union[str, "SessionHostLoadBalancingAlgorithm"]] = None, + peak_start_time: Optional["_models.Time"] = None, + peak_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, + ramp_down_start_time: Optional["_models.Time"] = None, + ramp_down_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, ramp_down_minimum_hosts_pct: Optional[int] = None, ramp_down_capacity_threshold_pct: Optional[int] = None, ramp_down_force_logoff_users: Optional[bool] = None, - ramp_down_stop_hosts_when: Optional[Union[str, "StopHostsWhen"]] = None, + ramp_down_stop_hosts_when: Optional[Union[str, "_models.StopHostsWhen"]] = None, ramp_down_wait_time_minutes: Optional[int] = None, ramp_down_notification_message: Optional[str] = None, - off_peak_start_time: Optional["Time"] = None, - off_peak_load_balancing_algorithm: Optional[Union[str, "SessionHostLoadBalancingAlgorithm"]] = None, + off_peak_start_time: Optional["_models.Time"] = None, + off_peak_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, **kwargs ): - super(ScalingSchedule, self).__init__(**kwargs) - self.name = name + """ + :keyword days_of_week: Set of days of the week on which this schedule is active. + :paramtype days_of_week: list[str or ~azure.mgmt.desktopvirtualization.models.DayOfWeek] + :keyword ramp_up_start_time: Starting time for ramp up period. + :paramtype ramp_up_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword ramp_up_load_balancing_algorithm: Load balancing algorithm for ramp up period. Known + values are: "BreadthFirst" and "DepthFirst". + :paramtype ramp_up_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_up_minimum_hosts_pct: Minimum host percentage for ramp up period. + :paramtype ramp_up_minimum_hosts_pct: int + :keyword ramp_up_capacity_threshold_pct: Capacity threshold for ramp up period. + :paramtype ramp_up_capacity_threshold_pct: int + :keyword peak_start_time: Starting time for peak period. + :paramtype peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword peak_load_balancing_algorithm: Load balancing algorithm for peak period. Known values + are: "BreadthFirst" and "DepthFirst". + :paramtype peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_down_start_time: Starting time for ramp down period. + :paramtype ramp_down_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword ramp_down_load_balancing_algorithm: Load balancing algorithm for ramp down period. + Known values are: "BreadthFirst" and "DepthFirst". + :paramtype ramp_down_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_down_minimum_hosts_pct: Minimum host percentage for ramp down period. + :paramtype ramp_down_minimum_hosts_pct: int + :keyword ramp_down_capacity_threshold_pct: Capacity threshold for ramp down period. + :paramtype ramp_down_capacity_threshold_pct: int + :keyword ramp_down_force_logoff_users: Should users be logged off forcefully from hosts. + :paramtype ramp_down_force_logoff_users: bool + :keyword ramp_down_stop_hosts_when: Specifies when to stop hosts during ramp down period. Known + values are: "ZeroSessions" and "ZeroActiveSessions". + :paramtype ramp_down_stop_hosts_when: str or + ~azure.mgmt.desktopvirtualization.models.StopHostsWhen + :keyword ramp_down_wait_time_minutes: Number of minutes to wait to stop hosts during ramp down + period. + :paramtype ramp_down_wait_time_minutes: int + :keyword ramp_down_notification_message: Notification message for users during ramp down + period. + :paramtype ramp_down_notification_message: str + :keyword off_peak_start_time: Starting time for off-peak period. + :paramtype off_peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword off_peak_load_balancing_algorithm: Load balancing algorithm for off-peak period. Known + values are: "BreadthFirst" and "DepthFirst". + :paramtype off_peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + """ + super().__init__(**kwargs) + self.system_data = None self.days_of_week = days_of_week self.ramp_up_start_time = ramp_up_start_time self.ramp_up_load_balancing_algorithm = ramp_up_load_balancing_algorithm @@ -2678,54 +3132,442 @@ def __init__( self.off_peak_load_balancing_algorithm = off_peak_load_balancing_algorithm -class SendMessage(msrest.serialization.Model): - """Represents message sent to a UserSession. +class ScalingPlanPooledScheduleList(_serialization.Model): + """List of ScalingPlanPooledSchedule definitions. - :param message_title: Title of message. - :type message_title: str - :param message_body: Body of message. - :type message_body: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of ScalingPlanPooledSchedule definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule] + :ivar next_link: Link to the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ScalingPlanPooledSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ScalingPlanPooledSchedule"]] = None, **kwargs): + """ + :keyword value: List of ScalingPlanPooledSchedule definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ScalingPlanPooledSchedulePatch(Resource): # pylint: disable=too-many-instance-attributes + """ScalingPlanPooledSchedule properties that can be patched. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar days_of_week: Set of days of the week on which this schedule is active. + :vartype days_of_week: list[str or ~azure.mgmt.desktopvirtualization.models.DayOfWeek] + :ivar ramp_up_start_time: Starting time for ramp up period. + :vartype ramp_up_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar ramp_up_load_balancing_algorithm: Load balancing algorithm for ramp up period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype ramp_up_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_up_minimum_hosts_pct: Minimum host percentage for ramp up period. + :vartype ramp_up_minimum_hosts_pct: int + :ivar ramp_up_capacity_threshold_pct: Capacity threshold for ramp up period. + :vartype ramp_up_capacity_threshold_pct: int + :ivar peak_start_time: Starting time for peak period. + :vartype peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar peak_load_balancing_algorithm: Load balancing algorithm for peak period. Known values + are: "BreadthFirst" and "DepthFirst". + :vartype peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_down_start_time: Starting time for ramp down period. + :vartype ramp_down_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar ramp_down_load_balancing_algorithm: Load balancing algorithm for ramp down period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype ramp_down_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_down_minimum_hosts_pct: Minimum host percentage for ramp down period. + :vartype ramp_down_minimum_hosts_pct: int + :ivar ramp_down_capacity_threshold_pct: Capacity threshold for ramp down period. + :vartype ramp_down_capacity_threshold_pct: int + :ivar ramp_down_force_logoff_users: Should users be logged off forcefully from hosts. + :vartype ramp_down_force_logoff_users: bool + :ivar ramp_down_stop_hosts_when: Specifies when to stop hosts during ramp down period. Known + values are: "ZeroSessions" and "ZeroActiveSessions". + :vartype ramp_down_stop_hosts_when: str or + ~azure.mgmt.desktopvirtualization.models.StopHostsWhen + :ivar ramp_down_wait_time_minutes: Number of minutes to wait to stop hosts during ramp down + period. + :vartype ramp_down_wait_time_minutes: int + :ivar ramp_down_notification_message: Notification message for users during ramp down period. + :vartype ramp_down_notification_message: str + :ivar off_peak_start_time: Starting time for off-peak period. + :vartype off_peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar off_peak_load_balancing_algorithm: Load balancing algorithm for off-peak period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype off_peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "ramp_up_minimum_hosts_pct": {"maximum": 100, "minimum": 0}, + "ramp_up_capacity_threshold_pct": {"maximum": 100, "minimum": 1}, + "ramp_down_minimum_hosts_pct": {"maximum": 100, "minimum": 0}, + "ramp_down_capacity_threshold_pct": {"maximum": 100, "minimum": 0}, + } + _attribute_map = { - 'message_title': {'key': 'messageTitle', 'type': 'str'}, - 'message_body': {'key': 'messageBody', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "days_of_week": {"key": "properties.daysOfWeek", "type": "[str]"}, + "ramp_up_start_time": {"key": "properties.rampUpStartTime", "type": "Time"}, + "ramp_up_load_balancing_algorithm": {"key": "properties.rampUpLoadBalancingAlgorithm", "type": "str"}, + "ramp_up_minimum_hosts_pct": {"key": "properties.rampUpMinimumHostsPct", "type": "int"}, + "ramp_up_capacity_threshold_pct": {"key": "properties.rampUpCapacityThresholdPct", "type": "int"}, + "peak_start_time": {"key": "properties.peakStartTime", "type": "Time"}, + "peak_load_balancing_algorithm": {"key": "properties.peakLoadBalancingAlgorithm", "type": "str"}, + "ramp_down_start_time": {"key": "properties.rampDownStartTime", "type": "Time"}, + "ramp_down_load_balancing_algorithm": {"key": "properties.rampDownLoadBalancingAlgorithm", "type": "str"}, + "ramp_down_minimum_hosts_pct": {"key": "properties.rampDownMinimumHostsPct", "type": "int"}, + "ramp_down_capacity_threshold_pct": {"key": "properties.rampDownCapacityThresholdPct", "type": "int"}, + "ramp_down_force_logoff_users": {"key": "properties.rampDownForceLogoffUsers", "type": "bool"}, + "ramp_down_stop_hosts_when": {"key": "properties.rampDownStopHostsWhen", "type": "str"}, + "ramp_down_wait_time_minutes": {"key": "properties.rampDownWaitTimeMinutes", "type": "int"}, + "ramp_down_notification_message": {"key": "properties.rampDownNotificationMessage", "type": "str"}, + "off_peak_start_time": {"key": "properties.offPeakStartTime", "type": "Time"}, + "off_peak_load_balancing_algorithm": {"key": "properties.offPeakLoadBalancingAlgorithm", "type": "str"}, } def __init__( self, *, - message_title: Optional[str] = None, - message_body: Optional[str] = None, + days_of_week: Optional[List[Union[str, "_models.DayOfWeek"]]] = None, + ramp_up_start_time: Optional["_models.Time"] = None, + ramp_up_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, + ramp_up_minimum_hosts_pct: Optional[int] = None, + ramp_up_capacity_threshold_pct: Optional[int] = None, + peak_start_time: Optional["_models.Time"] = None, + peak_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, + ramp_down_start_time: Optional["_models.Time"] = None, + ramp_down_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, + ramp_down_minimum_hosts_pct: Optional[int] = None, + ramp_down_capacity_threshold_pct: Optional[int] = None, + ramp_down_force_logoff_users: Optional[bool] = None, + ramp_down_stop_hosts_when: Optional[Union[str, "_models.StopHostsWhen"]] = None, + ramp_down_wait_time_minutes: Optional[int] = None, + ramp_down_notification_message: Optional[str] = None, + off_peak_start_time: Optional["_models.Time"] = None, + off_peak_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, **kwargs ): - super(SendMessage, self).__init__(**kwargs) - self.message_title = message_title - self.message_body = message_body + """ + :keyword days_of_week: Set of days of the week on which this schedule is active. + :paramtype days_of_week: list[str or ~azure.mgmt.desktopvirtualization.models.DayOfWeek] + :keyword ramp_up_start_time: Starting time for ramp up period. + :paramtype ramp_up_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword ramp_up_load_balancing_algorithm: Load balancing algorithm for ramp up period. Known + values are: "BreadthFirst" and "DepthFirst". + :paramtype ramp_up_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_up_minimum_hosts_pct: Minimum host percentage for ramp up period. + :paramtype ramp_up_minimum_hosts_pct: int + :keyword ramp_up_capacity_threshold_pct: Capacity threshold for ramp up period. + :paramtype ramp_up_capacity_threshold_pct: int + :keyword peak_start_time: Starting time for peak period. + :paramtype peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword peak_load_balancing_algorithm: Load balancing algorithm for peak period. Known values + are: "BreadthFirst" and "DepthFirst". + :paramtype peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_down_start_time: Starting time for ramp down period. + :paramtype ramp_down_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword ramp_down_load_balancing_algorithm: Load balancing algorithm for ramp down period. + Known values are: "BreadthFirst" and "DepthFirst". + :paramtype ramp_down_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_down_minimum_hosts_pct: Minimum host percentage for ramp down period. + :paramtype ramp_down_minimum_hosts_pct: int + :keyword ramp_down_capacity_threshold_pct: Capacity threshold for ramp down period. + :paramtype ramp_down_capacity_threshold_pct: int + :keyword ramp_down_force_logoff_users: Should users be logged off forcefully from hosts. + :paramtype ramp_down_force_logoff_users: bool + :keyword ramp_down_stop_hosts_when: Specifies when to stop hosts during ramp down period. Known + values are: "ZeroSessions" and "ZeroActiveSessions". + :paramtype ramp_down_stop_hosts_when: str or + ~azure.mgmt.desktopvirtualization.models.StopHostsWhen + :keyword ramp_down_wait_time_minutes: Number of minutes to wait to stop hosts during ramp down + period. + :paramtype ramp_down_wait_time_minutes: int + :keyword ramp_down_notification_message: Notification message for users during ramp down + period. + :paramtype ramp_down_notification_message: str + :keyword off_peak_start_time: Starting time for off-peak period. + :paramtype off_peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword off_peak_load_balancing_algorithm: Load balancing algorithm for off-peak period. Known + values are: "BreadthFirst" and "DepthFirst". + :paramtype off_peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + """ + super().__init__(**kwargs) + self.days_of_week = days_of_week + self.ramp_up_start_time = ramp_up_start_time + self.ramp_up_load_balancing_algorithm = ramp_up_load_balancing_algorithm + self.ramp_up_minimum_hosts_pct = ramp_up_minimum_hosts_pct + self.ramp_up_capacity_threshold_pct = ramp_up_capacity_threshold_pct + self.peak_start_time = peak_start_time + self.peak_load_balancing_algorithm = peak_load_balancing_algorithm + self.ramp_down_start_time = ramp_down_start_time + self.ramp_down_load_balancing_algorithm = ramp_down_load_balancing_algorithm + self.ramp_down_minimum_hosts_pct = ramp_down_minimum_hosts_pct + self.ramp_down_capacity_threshold_pct = ramp_down_capacity_threshold_pct + self.ramp_down_force_logoff_users = ramp_down_force_logoff_users + self.ramp_down_stop_hosts_when = ramp_down_stop_hosts_when + self.ramp_down_wait_time_minutes = ramp_down_wait_time_minutes + self.ramp_down_notification_message = ramp_down_notification_message + self.off_peak_start_time = off_peak_start_time + self.off_peak_load_balancing_algorithm = off_peak_load_balancing_algorithm -class ServiceSpecification(msrest.serialization.Model): - """Service specification payload. +class ScalingSchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes + """A ScalingPlanPooledSchedule. - :param log_specifications: Specifications of the Log for Azure Monitoring. - :type log_specifications: list[~desktop_virtualization_api_client.models.LogSpecification] + :ivar name: Name of the ScalingPlanPooledSchedule. + :vartype name: str + :ivar days_of_week: Set of days of the week on which this schedule is active. + :vartype days_of_week: list[str or + ~azure.mgmt.desktopvirtualization.models.ScalingScheduleDaysOfWeekItem] + :ivar ramp_up_start_time: Starting time for ramp up period. + :vartype ramp_up_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar ramp_up_load_balancing_algorithm: Load balancing algorithm for ramp up period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype ramp_up_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_up_minimum_hosts_pct: Minimum host percentage for ramp up period. + :vartype ramp_up_minimum_hosts_pct: int + :ivar ramp_up_capacity_threshold_pct: Capacity threshold for ramp up period. + :vartype ramp_up_capacity_threshold_pct: int + :ivar peak_start_time: Starting time for peak period. + :vartype peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar peak_load_balancing_algorithm: Load balancing algorithm for peak period. Known values + are: "BreadthFirst" and "DepthFirst". + :vartype peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_down_start_time: Starting time for ramp down period. + :vartype ramp_down_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar ramp_down_load_balancing_algorithm: Load balancing algorithm for ramp down period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype ramp_down_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :ivar ramp_down_minimum_hosts_pct: Minimum host percentage for ramp down period. + :vartype ramp_down_minimum_hosts_pct: int + :ivar ramp_down_capacity_threshold_pct: Capacity threshold for ramp down period. + :vartype ramp_down_capacity_threshold_pct: int + :ivar ramp_down_force_logoff_users: Should users be logged off forcefully from hosts. + :vartype ramp_down_force_logoff_users: bool + :ivar ramp_down_stop_hosts_when: Specifies when to stop hosts during ramp down period. Known + values are: "ZeroSessions" and "ZeroActiveSessions". + :vartype ramp_down_stop_hosts_when: str or + ~azure.mgmt.desktopvirtualization.models.StopHostsWhen + :ivar ramp_down_wait_time_minutes: Number of minutes to wait to stop hosts during ramp down + period. + :vartype ramp_down_wait_time_minutes: int + :ivar ramp_down_notification_message: Notification message for users during ramp down period. + :vartype ramp_down_notification_message: str + :ivar off_peak_start_time: Starting time for off-peak period. + :vartype off_peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :ivar off_peak_load_balancing_algorithm: Load balancing algorithm for off-peak period. Known + values are: "BreadthFirst" and "DepthFirst". + :vartype off_peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm """ + _validation = { + "ramp_up_minimum_hosts_pct": {"maximum": 100, "minimum": 0}, + "ramp_up_capacity_threshold_pct": {"maximum": 100, "minimum": 1}, + "ramp_down_minimum_hosts_pct": {"maximum": 100, "minimum": 0}, + "ramp_down_capacity_threshold_pct": {"maximum": 100, "minimum": 0}, + } + _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, + "name": {"key": "name", "type": "str"}, + "days_of_week": {"key": "daysOfWeek", "type": "[str]"}, + "ramp_up_start_time": {"key": "rampUpStartTime", "type": "Time"}, + "ramp_up_load_balancing_algorithm": {"key": "rampUpLoadBalancingAlgorithm", "type": "str"}, + "ramp_up_minimum_hosts_pct": {"key": "rampUpMinimumHostsPct", "type": "int"}, + "ramp_up_capacity_threshold_pct": {"key": "rampUpCapacityThresholdPct", "type": "int"}, + "peak_start_time": {"key": "peakStartTime", "type": "Time"}, + "peak_load_balancing_algorithm": {"key": "peakLoadBalancingAlgorithm", "type": "str"}, + "ramp_down_start_time": {"key": "rampDownStartTime", "type": "Time"}, + "ramp_down_load_balancing_algorithm": {"key": "rampDownLoadBalancingAlgorithm", "type": "str"}, + "ramp_down_minimum_hosts_pct": {"key": "rampDownMinimumHostsPct", "type": "int"}, + "ramp_down_capacity_threshold_pct": {"key": "rampDownCapacityThresholdPct", "type": "int"}, + "ramp_down_force_logoff_users": {"key": "rampDownForceLogoffUsers", "type": "bool"}, + "ramp_down_stop_hosts_when": {"key": "rampDownStopHostsWhen", "type": "str"}, + "ramp_down_wait_time_minutes": {"key": "rampDownWaitTimeMinutes", "type": "int"}, + "ramp_down_notification_message": {"key": "rampDownNotificationMessage", "type": "str"}, + "off_peak_start_time": {"key": "offPeakStartTime", "type": "Time"}, + "off_peak_load_balancing_algorithm": {"key": "offPeakLoadBalancingAlgorithm", "type": "str"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, + name: Optional[str] = None, + days_of_week: Optional[List[Union[str, "_models.ScalingScheduleDaysOfWeekItem"]]] = None, + ramp_up_start_time: Optional["_models.Time"] = None, + ramp_up_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, + ramp_up_minimum_hosts_pct: Optional[int] = None, + ramp_up_capacity_threshold_pct: Optional[int] = None, + peak_start_time: Optional["_models.Time"] = None, + peak_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, + ramp_down_start_time: Optional["_models.Time"] = None, + ramp_down_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, + ramp_down_minimum_hosts_pct: Optional[int] = None, + ramp_down_capacity_threshold_pct: Optional[int] = None, + ramp_down_force_logoff_users: Optional[bool] = None, + ramp_down_stop_hosts_when: Optional[Union[str, "_models.StopHostsWhen"]] = None, + ramp_down_wait_time_minutes: Optional[int] = None, + ramp_down_notification_message: Optional[str] = None, + off_peak_start_time: Optional["_models.Time"] = None, + off_peak_load_balancing_algorithm: Optional[Union[str, "_models.SessionHostLoadBalancingAlgorithm"]] = None, **kwargs ): - super(ServiceSpecification, self).__init__(**kwargs) + """ + :keyword name: Name of the ScalingPlanPooledSchedule. + :paramtype name: str + :keyword days_of_week: Set of days of the week on which this schedule is active. + :paramtype days_of_week: list[str or + ~azure.mgmt.desktopvirtualization.models.ScalingScheduleDaysOfWeekItem] + :keyword ramp_up_start_time: Starting time for ramp up period. + :paramtype ramp_up_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword ramp_up_load_balancing_algorithm: Load balancing algorithm for ramp up period. Known + values are: "BreadthFirst" and "DepthFirst". + :paramtype ramp_up_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_up_minimum_hosts_pct: Minimum host percentage for ramp up period. + :paramtype ramp_up_minimum_hosts_pct: int + :keyword ramp_up_capacity_threshold_pct: Capacity threshold for ramp up period. + :paramtype ramp_up_capacity_threshold_pct: int + :keyword peak_start_time: Starting time for peak period. + :paramtype peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword peak_load_balancing_algorithm: Load balancing algorithm for peak period. Known values + are: "BreadthFirst" and "DepthFirst". + :paramtype peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_down_start_time: Starting time for ramp down period. + :paramtype ramp_down_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword ramp_down_load_balancing_algorithm: Load balancing algorithm for ramp down period. + Known values are: "BreadthFirst" and "DepthFirst". + :paramtype ramp_down_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + :keyword ramp_down_minimum_hosts_pct: Minimum host percentage for ramp down period. + :paramtype ramp_down_minimum_hosts_pct: int + :keyword ramp_down_capacity_threshold_pct: Capacity threshold for ramp down period. + :paramtype ramp_down_capacity_threshold_pct: int + :keyword ramp_down_force_logoff_users: Should users be logged off forcefully from hosts. + :paramtype ramp_down_force_logoff_users: bool + :keyword ramp_down_stop_hosts_when: Specifies when to stop hosts during ramp down period. Known + values are: "ZeroSessions" and "ZeroActiveSessions". + :paramtype ramp_down_stop_hosts_when: str or + ~azure.mgmt.desktopvirtualization.models.StopHostsWhen + :keyword ramp_down_wait_time_minutes: Number of minutes to wait to stop hosts during ramp down + period. + :paramtype ramp_down_wait_time_minutes: int + :keyword ramp_down_notification_message: Notification message for users during ramp down + period. + :paramtype ramp_down_notification_message: str + :keyword off_peak_start_time: Starting time for off-peak period. + :paramtype off_peak_start_time: ~azure.mgmt.desktopvirtualization.models.Time + :keyword off_peak_load_balancing_algorithm: Load balancing algorithm for off-peak period. Known + values are: "BreadthFirst" and "DepthFirst". + :paramtype off_peak_load_balancing_algorithm: str or + ~azure.mgmt.desktopvirtualization.models.SessionHostLoadBalancingAlgorithm + """ + super().__init__(**kwargs) + self.name = name + self.days_of_week = days_of_week + self.ramp_up_start_time = ramp_up_start_time + self.ramp_up_load_balancing_algorithm = ramp_up_load_balancing_algorithm + self.ramp_up_minimum_hosts_pct = ramp_up_minimum_hosts_pct + self.ramp_up_capacity_threshold_pct = ramp_up_capacity_threshold_pct + self.peak_start_time = peak_start_time + self.peak_load_balancing_algorithm = peak_load_balancing_algorithm + self.ramp_down_start_time = ramp_down_start_time + self.ramp_down_load_balancing_algorithm = ramp_down_load_balancing_algorithm + self.ramp_down_minimum_hosts_pct = ramp_down_minimum_hosts_pct + self.ramp_down_capacity_threshold_pct = ramp_down_capacity_threshold_pct + self.ramp_down_force_logoff_users = ramp_down_force_logoff_users + self.ramp_down_stop_hosts_when = ramp_down_stop_hosts_when + self.ramp_down_wait_time_minutes = ramp_down_wait_time_minutes + self.ramp_down_notification_message = ramp_down_notification_message + self.off_peak_start_time = off_peak_start_time + self.off_peak_load_balancing_algorithm = off_peak_load_balancing_algorithm + + +class SendMessage(_serialization.Model): + """Represents message sent to a UserSession. + + :ivar message_title: Title of message. + :vartype message_title: str + :ivar message_body: Body of message. + :vartype message_body: str + """ + + _attribute_map = { + "message_title": {"key": "messageTitle", "type": "str"}, + "message_body": {"key": "messageBody", "type": "str"}, + } + + def __init__(self, *, message_title: Optional[str] = None, message_body: Optional[str] = None, **kwargs): + """ + :keyword message_title: Title of message. + :paramtype message_title: str + :keyword message_body: Body of message. + :paramtype message_body: str + """ + super().__init__(**kwargs) + self.message_title = message_title + self.message_body = message_body + + +class ServiceSpecification(_serialization.Model): + """Service specification payload. + + :ivar log_specifications: Specifications of the Log for Azure Monitoring. + :vartype log_specifications: list[~azure.mgmt.desktopvirtualization.models.LogSpecification] + """ + + _attribute_map = { + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + } + + def __init__(self, *, log_specifications: Optional[List["_models.LogSpecification"]] = None, **kwargs): + """ + :keyword log_specifications: Specifications of the Log for Azure Monitoring. + :paramtype log_specifications: list[~azure.mgmt.desktopvirtualization.models.LogSpecification] + """ + super().__init__(**kwargs) self.log_specifications = log_specifications -class SessionHost(Resource): +class SessionHost(Resource): # pylint: disable=too-many-instance-attributes """Represents a SessionHost definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -2739,80 +3581,86 @@ class SessionHost(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData :ivar object_id: ObjectId of SessionHost. (internal use). :vartype object_id: str - :param last_heart_beat: Last heart beat from SessionHost. - :type last_heart_beat: ~datetime.datetime - :param sessions: Number of sessions on SessionHost. - :type sessions: int - :param agent_version: Version of agent on SessionHost. - :type agent_version: str - :param allow_new_session: Allow a new session. - :type allow_new_session: bool + :ivar last_heart_beat: Last heart beat from SessionHost. + :vartype last_heart_beat: ~datetime.datetime + :ivar sessions: Number of sessions on SessionHost. + :vartype sessions: int + :ivar agent_version: Version of agent on SessionHost. + :vartype agent_version: str + :ivar allow_new_session: Allow a new session. + :vartype allow_new_session: bool :ivar virtual_machine_id: Virtual Machine Id of SessionHost's underlying virtual machine. :vartype virtual_machine_id: str :ivar resource_id: Resource Id of SessionHost's underlying virtual machine. :vartype resource_id: str - :param assigned_user: User assigned to SessionHost. - :type assigned_user: str - :param status: Status for a SessionHost. Possible values include: "Available", "Unavailable", + :ivar assigned_user: User assigned to SessionHost. + :vartype assigned_user: str + :ivar friendly_name: Friendly name of SessionHost. + :vartype friendly_name: str + :ivar status: Status for a SessionHost. Known values are: "Available", "Unavailable", "Shutdown", "Disconnected", "Upgrading", "UpgradeFailed", "NoHeartbeat", "NotJoinedToDomain", - "DomainTrustRelationshipLost", "SxSStackListenerNotReady", "FSLogixNotHealthy", + "DomainTrustRelationshipLost", "SxSStackListenerNotReady", "FSLogixNotHealthy", and "NeedsAssistance". - :type status: str or ~desktop_virtualization_api_client.models.Status + :vartype status: str or ~azure.mgmt.desktopvirtualization.models.Status :ivar status_timestamp: The timestamp of the status. :vartype status_timestamp: ~datetime.datetime - :param os_version: The version of the OS on the session host. - :type os_version: str - :param sx_s_stack_version: The version of the side by side stack on the session host. - :type sx_s_stack_version: str - :param update_state: Update state of a SessionHost. Possible values include: "Initial", - "Pending", "Started", "Succeeded", "Failed". - :type update_state: str or ~desktop_virtualization_api_client.models.UpdateState + :ivar os_version: The version of the OS on the session host. + :vartype os_version: str + :ivar sx_s_stack_version: The version of the side by side stack on the session host. + :vartype sx_s_stack_version: str + :ivar update_state: Update state of a SessionHost. Known values are: "Initial", "Pending", + "Started", "Succeeded", and "Failed". + :vartype update_state: str or ~azure.mgmt.desktopvirtualization.models.UpdateState :ivar last_update_time: The timestamp of the last update. :vartype last_update_time: ~datetime.datetime - :param update_error_message: The error message. - :type update_error_message: str + :ivar update_error_message: The error message. + :vartype update_error_message: str :ivar session_host_health_check_results: List of SessionHostHealthCheckReports. :vartype session_host_health_check_results: - list[~desktop_virtualization_api_client.models.SessionHostHealthCheckReport] + list[~azure.mgmt.desktopvirtualization.models.SessionHostHealthCheckReport] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'virtual_machine_id': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'status_timestamp': {'readonly': True}, - 'last_update_time': {'readonly': True}, - 'session_host_health_check_results': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'last_heart_beat': {'key': 'properties.lastHeartBeat', 'type': 'iso-8601'}, - 'sessions': {'key': 'properties.sessions', 'type': 'int'}, - 'agent_version': {'key': 'properties.agentVersion', 'type': 'str'}, - 'allow_new_session': {'key': 'properties.allowNewSession', 'type': 'bool'}, - 'virtual_machine_id': {'key': 'properties.virtualMachineId', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'assigned_user': {'key': 'properties.assignedUser', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_timestamp': {'key': 'properties.statusTimestamp', 'type': 'iso-8601'}, - 'os_version': {'key': 'properties.osVersion', 'type': 'str'}, - 'sx_s_stack_version': {'key': 'properties.sxSStackVersion', 'type': 'str'}, - 'update_state': {'key': 'properties.updateState', 'type': 'str'}, - 'last_update_time': {'key': 'properties.lastUpdateTime', 'type': 'iso-8601'}, - 'update_error_message': {'key': 'properties.updateErrorMessage', 'type': 'str'}, - 'session_host_health_check_results': {'key': 'properties.sessionHostHealthCheckResults', 'type': '[SessionHostHealthCheckReport]'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "object_id": {"readonly": True}, + "virtual_machine_id": {"readonly": True}, + "resource_id": {"readonly": True}, + "status_timestamp": {"readonly": True}, + "last_update_time": {"readonly": True}, + "session_host_health_check_results": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "last_heart_beat": {"key": "properties.lastHeartBeat", "type": "iso-8601"}, + "sessions": {"key": "properties.sessions", "type": "int"}, + "agent_version": {"key": "properties.agentVersion", "type": "str"}, + "allow_new_session": {"key": "properties.allowNewSession", "type": "bool"}, + "virtual_machine_id": {"key": "properties.virtualMachineId", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "assigned_user": {"key": "properties.assignedUser", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "status_timestamp": {"key": "properties.statusTimestamp", "type": "iso-8601"}, + "os_version": {"key": "properties.osVersion", "type": "str"}, + "sx_s_stack_version": {"key": "properties.sxSStackVersion", "type": "str"}, + "update_state": {"key": "properties.updateState", "type": "str"}, + "last_update_time": {"key": "properties.lastUpdateTime", "type": "iso-8601"}, + "update_error_message": {"key": "properties.updateErrorMessage", "type": "str"}, + "session_host_health_check_results": { + "key": "properties.sessionHostHealthCheckResults", + "type": "[SessionHostHealthCheckReport]", + }, } def __init__( @@ -2823,14 +3671,43 @@ def __init__( agent_version: Optional[str] = None, allow_new_session: Optional[bool] = None, assigned_user: Optional[str] = None, - status: Optional[Union[str, "Status"]] = None, + friendly_name: Optional[str] = None, + status: Optional[Union[str, "_models.Status"]] = None, os_version: Optional[str] = None, sx_s_stack_version: Optional[str] = None, - update_state: Optional[Union[str, "UpdateState"]] = None, + update_state: Optional[Union[str, "_models.UpdateState"]] = None, update_error_message: Optional[str] = None, **kwargs ): - super(SessionHost, self).__init__(**kwargs) + """ + :keyword last_heart_beat: Last heart beat from SessionHost. + :paramtype last_heart_beat: ~datetime.datetime + :keyword sessions: Number of sessions on SessionHost. + :paramtype sessions: int + :keyword agent_version: Version of agent on SessionHost. + :paramtype agent_version: str + :keyword allow_new_session: Allow a new session. + :paramtype allow_new_session: bool + :keyword assigned_user: User assigned to SessionHost. + :paramtype assigned_user: str + :keyword friendly_name: Friendly name of SessionHost. + :paramtype friendly_name: str + :keyword status: Status for a SessionHost. Known values are: "Available", "Unavailable", + "Shutdown", "Disconnected", "Upgrading", "UpgradeFailed", "NoHeartbeat", "NotJoinedToDomain", + "DomainTrustRelationshipLost", "SxSStackListenerNotReady", "FSLogixNotHealthy", and + "NeedsAssistance". + :paramtype status: str or ~azure.mgmt.desktopvirtualization.models.Status + :keyword os_version: The version of the OS on the session host. + :paramtype os_version: str + :keyword sx_s_stack_version: The version of the side by side stack on the session host. + :paramtype sx_s_stack_version: str + :keyword update_state: Update state of a SessionHost. Known values are: "Initial", "Pending", + "Started", "Succeeded", and "Failed". + :paramtype update_state: str or ~azure.mgmt.desktopvirtualization.models.UpdateState + :keyword update_error_message: The error message. + :paramtype update_error_message: str + """ + super().__init__(**kwargs) self.system_data = None self.object_id = None self.last_heart_beat = last_heart_beat @@ -2840,6 +3717,7 @@ def __init__( self.virtual_machine_id = None self.resource_id = None self.assigned_user = assigned_user + self.friendly_name = friendly_name self.status = status self.status_timestamp = None self.os_version = os_version @@ -2850,7 +3728,7 @@ def __init__( self.session_host_health_check_results = None -class SessionHostHealthCheckFailureDetails(msrest.serialization.Model): +class SessionHostHealthCheckFailureDetails(_serialization.Model): """Contains details on the failure. Variables are only populated by the server, and will be ignored when sending a request. @@ -2864,97 +3742,93 @@ class SessionHostHealthCheckFailureDetails(msrest.serialization.Model): """ _validation = { - 'message': {'readonly': True}, - 'error_code': {'readonly': True}, - 'last_health_check_date_time': {'readonly': True}, + "message": {"readonly": True}, + "error_code": {"readonly": True}, + "last_health_check_date_time": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'int'}, - 'last_health_check_date_time': {'key': 'lastHealthCheckDateTime', 'type': 'iso-8601'}, + "message": {"key": "message", "type": "str"}, + "error_code": {"key": "errorCode", "type": "int"}, + "last_health_check_date_time": {"key": "lastHealthCheckDateTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - super(SessionHostHealthCheckFailureDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.message = None self.error_code = None self.last_health_check_date_time = None -class SessionHostHealthCheckReport(msrest.serialization.Model): +class SessionHostHealthCheckReport(_serialization.Model): """The report for session host information. Variables are only populated by the server, and will be ignored when sending a request. - :ivar health_check_name: Represents the name of the health check operation performed. Possible - values include: "DomainJoinedCheck", "DomainTrustCheck", "FSLogixHealthCheck", + :ivar health_check_name: Represents the name of the health check operation performed. Known + values are: "DomainJoinedCheck", "DomainTrustCheck", "FSLogixHealthCheck", "SxSStackListenerCheck", "UrlsAccessibleCheck", "MonitoringAgentCheck", "DomainReachable", - "WebRTCRedirectorCheck", "SupportedEncryptionCheck", "MetaDataServiceCheck", + "WebRTCRedirectorCheck", "SupportedEncryptionCheck", "MetaDataServiceCheck", and "AppAttachHealthCheck". - :vartype health_check_name: str or ~desktop_virtualization_api_client.models.HealthCheckName - :ivar health_check_result: Represents the Health state of the health check we performed. - Possible values include: "Unknown", "HealthCheckSucceeded", "HealthCheckFailed", - "SessionHostShutdown". - :vartype health_check_result: str or - ~desktop_virtualization_api_client.models.HealthCheckResult + :vartype health_check_name: str or ~azure.mgmt.desktopvirtualization.models.HealthCheckName + :ivar health_check_result: Represents the Health state of the health check we performed. Known + values are: "Unknown", "HealthCheckSucceeded", "HealthCheckFailed", and "SessionHostShutdown". + :vartype health_check_result: str or ~azure.mgmt.desktopvirtualization.models.HealthCheckResult :ivar additional_failure_details: Additional detailed information on the failure. :vartype additional_failure_details: - ~desktop_virtualization_api_client.models.SessionHostHealthCheckFailureDetails + ~azure.mgmt.desktopvirtualization.models.SessionHostHealthCheckFailureDetails """ _validation = { - 'health_check_name': {'readonly': True}, - 'health_check_result': {'readonly': True}, - 'additional_failure_details': {'readonly': True}, + "health_check_name": {"readonly": True}, + "health_check_result": {"readonly": True}, + "additional_failure_details": {"readonly": True}, } _attribute_map = { - 'health_check_name': {'key': 'healthCheckName', 'type': 'str'}, - 'health_check_result': {'key': 'healthCheckResult', 'type': 'str'}, - 'additional_failure_details': {'key': 'additionalFailureDetails', 'type': 'SessionHostHealthCheckFailureDetails'}, + "health_check_name": {"key": "healthCheckName", "type": "str"}, + "health_check_result": {"key": "healthCheckResult", "type": "str"}, + "additional_failure_details": { + "key": "additionalFailureDetails", + "type": "SessionHostHealthCheckFailureDetails", + }, } - def __init__( - self, - **kwargs - ): - super(SessionHostHealthCheckReport, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.health_check_name = None self.health_check_result = None self.additional_failure_details = None -class SessionHostList(msrest.serialization.Model): +class SessionHostList(_serialization.Model): """List of SessionHost definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of SessionHost definitions. - :type value: list[~desktop_virtualization_api_client.models.SessionHost] + :ivar value: List of SessionHost definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.SessionHost] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SessionHost]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SessionHost]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["SessionHost"]] = None, - **kwargs - ): - super(SessionHostList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.SessionHost"]] = None, **kwargs): + """ + :keyword value: List of SessionHost definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.SessionHost] + """ + super().__init__(**kwargs) self.value = value self.next_link = None @@ -2972,24 +3846,27 @@ class SessionHostPatch(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param allow_new_session: Allow a new session. - :type allow_new_session: bool - :param assigned_user: User assigned to SessionHost. - :type assigned_user: str + :ivar allow_new_session: Allow a new session. + :vartype allow_new_session: bool + :ivar assigned_user: User assigned to SessionHost. + :vartype assigned_user: str + :ivar friendly_name: Friendly name of SessionHost. + :vartype friendly_name: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, - 'allow_new_session': {'key': 'properties.allowNewSession', 'type': 'bool'}, - 'assigned_user': {'key': 'properties.assignedUser', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "allow_new_session": {"key": "properties.allowNewSession", "type": "bool"}, + "assigned_user": {"key": "properties.assignedUser", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, } def __init__( @@ -2997,11 +3874,21 @@ def __init__( *, allow_new_session: Optional[bool] = None, assigned_user: Optional[str] = None, + friendly_name: Optional[str] = None, **kwargs ): - super(SessionHostPatch, self).__init__(**kwargs) + """ + :keyword allow_new_session: Allow a new session. + :paramtype allow_new_session: bool + :keyword assigned_user: User assigned to SessionHost. + :paramtype assigned_user: str + :keyword friendly_name: Friendly name of SessionHost. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) self.allow_new_session = allow_new_session self.assigned_user = assigned_user + self.friendly_name = friendly_name class StartMenuItem(Resource): @@ -3017,33 +3904,33 @@ class StartMenuItem(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param app_alias: Alias of StartMenuItem. - :type app_alias: str - :param file_path: Path to the file of StartMenuItem. - :type file_path: str - :param command_line_arguments: Command line arguments for StartMenuItem. - :type command_line_arguments: str - :param icon_path: Path to the icon. - :type icon_path: str - :param icon_index: Index of the icon. - :type icon_index: int + :ivar app_alias: Alias of StartMenuItem. + :vartype app_alias: str + :ivar file_path: Path to the file of StartMenuItem. + :vartype file_path: str + :ivar command_line_arguments: Command line arguments for StartMenuItem. + :vartype command_line_arguments: str + :ivar icon_path: Path to the icon. + :vartype icon_path: str + :ivar icon_index: Index of the icon. + :vartype icon_index: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, - 'app_alias': {'key': 'properties.appAlias', 'type': 'str'}, - 'file_path': {'key': 'properties.filePath', 'type': 'str'}, - 'command_line_arguments': {'key': 'properties.commandLineArguments', 'type': 'str'}, - 'icon_path': {'key': 'properties.iconPath', 'type': 'str'}, - 'icon_index': {'key': 'properties.iconIndex', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "app_alias": {"key": "properties.appAlias", "type": "str"}, + "file_path": {"key": "properties.filePath", "type": "str"}, + "command_line_arguments": {"key": "properties.commandLineArguments", "type": "str"}, + "icon_path": {"key": "properties.iconPath", "type": "str"}, + "icon_index": {"key": "properties.iconIndex", "type": "int"}, } def __init__( @@ -3056,7 +3943,19 @@ def __init__( icon_index: Optional[int] = None, **kwargs ): - super(StartMenuItem, self).__init__(**kwargs) + """ + :keyword app_alias: Alias of StartMenuItem. + :paramtype app_alias: str + :keyword file_path: Path to the file of StartMenuItem. + :paramtype file_path: str + :keyword command_line_arguments: Command line arguments for StartMenuItem. + :paramtype command_line_arguments: str + :keyword icon_path: Path to the icon. + :paramtype icon_path: str + :keyword icon_index: Index of the icon. + :paramtype icon_index: int + """ + super().__init__(**kwargs) self.app_alias = app_alias self.file_path = file_path self.command_line_arguments = command_line_arguments @@ -3064,77 +3963,92 @@ def __init__( self.icon_index = icon_index -class StartMenuItemList(msrest.serialization.Model): +class StartMenuItemList(_serialization.Model): """List of StartMenuItem definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of StartMenuItem definitions. - :type value: list[~desktop_virtualization_api_client.models.StartMenuItem] + :ivar value: List of StartMenuItem definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.StartMenuItem] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StartMenuItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StartMenuItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["StartMenuItem"]] = None, - **kwargs - ): - super(StartMenuItemList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.StartMenuItem"]] = None, **kwargs): + """ + :keyword value: List of StartMenuItem definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.StartMenuItem] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~desktop_virtualization_api_client.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~desktop_virtualization_api_client.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.desktopvirtualization.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.desktopvirtualization.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'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SystemData, self).__init__(**kwargs) + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.desktopvirtualization.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.desktopvirtualization.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -3143,35 +4057,35 @@ def __init__( self.last_modified_at = last_modified_at -class Time(msrest.serialization.Model): +class Time(_serialization.Model): """The time for a scaling action to occur. All required parameters must be populated in order to send to Azure. - :param hour: Required. The hour. - :type hour: int - :param minute: Required. The minute. - :type minute: int + :ivar hour: The hour. Required. + :vartype hour: int + :ivar minute: The minute. Required. + :vartype minute: int """ _validation = { - 'hour': {'required': True, 'maximum': 23, 'minimum': 0}, - 'minute': {'required': True, 'maximum': 59, 'minimum': 0}, + "hour": {"required": True, "maximum": 23, "minimum": 0}, + "minute": {"required": True, "maximum": 59, "minimum": 0}, } _attribute_map = { - 'hour': {'key': 'hour', 'type': 'int'}, - 'minute': {'key': 'minute', 'type': 'int'}, + "hour": {"key": "hour", "type": "int"}, + "minute": {"key": "minute", "type": "int"}, } - def __init__( - self, - *, - hour: int, - minute: int, - **kwargs - ): - super(Time, self).__init__(**kwargs) + def __init__(self, *, hour: int, minute: int, **kwargs): + """ + :keyword hour: The hour. Required. + :paramtype hour: int + :keyword minute: The minute. Required. + :paramtype minute: int + """ + super().__init__(**kwargs) self.hour = hour self.minute = minute @@ -3190,55 +4104,69 @@ class UserSession(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData :ivar object_id: ObjectId of user session. (internal use). :vartype object_id: str - :param user_principal_name: The user principal name. - :type user_principal_name: str - :param application_type: Application type of application. Possible values include: "RemoteApp", + :ivar user_principal_name: The user principal name. + :vartype user_principal_name: str + :ivar application_type: Application type of application. Known values are: "RemoteApp" and "Desktop". - :type application_type: str or ~desktop_virtualization_api_client.models.ApplicationType - :param session_state: State of user session. Possible values include: "Unknown", "Active", - "Disconnected", "Pending", "LogOff", "UserProfileDiskMounted". - :type session_state: str or ~desktop_virtualization_api_client.models.SessionState - :param active_directory_user_name: The active directory user name. - :type active_directory_user_name: str - :param create_time: The timestamp of the user session create. - :type create_time: ~datetime.datetime + :vartype application_type: str or ~azure.mgmt.desktopvirtualization.models.ApplicationType + :ivar session_state: State of user session. Known values are: "Unknown", "Active", + "Disconnected", "Pending", "LogOff", and "UserProfileDiskMounted". + :vartype session_state: str or ~azure.mgmt.desktopvirtualization.models.SessionState + :ivar active_directory_user_name: The active directory user name. + :vartype active_directory_user_name: str + :ivar create_time: The timestamp of the user session create. + :vartype create_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "object_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'user_principal_name': {'key': 'properties.userPrincipalName', 'type': 'str'}, - 'application_type': {'key': 'properties.applicationType', 'type': 'str'}, - 'session_state': {'key': 'properties.sessionState', 'type': 'str'}, - 'active_directory_user_name': {'key': 'properties.activeDirectoryUserName', 'type': 'str'}, - 'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "user_principal_name": {"key": "properties.userPrincipalName", "type": "str"}, + "application_type": {"key": "properties.applicationType", "type": "str"}, + "session_state": {"key": "properties.sessionState", "type": "str"}, + "active_directory_user_name": {"key": "properties.activeDirectoryUserName", "type": "str"}, + "create_time": {"key": "properties.createTime", "type": "iso-8601"}, } def __init__( self, *, user_principal_name: Optional[str] = None, - application_type: Optional[Union[str, "ApplicationType"]] = None, - session_state: Optional[Union[str, "SessionState"]] = None, + application_type: Optional[Union[str, "_models.ApplicationType"]] = None, + session_state: Optional[Union[str, "_models.SessionState"]] = None, active_directory_user_name: Optional[str] = None, create_time: Optional[datetime.datetime] = None, **kwargs ): - super(UserSession, self).__init__(**kwargs) + """ + :keyword user_principal_name: The user principal name. + :paramtype user_principal_name: str + :keyword application_type: Application type of application. Known values are: "RemoteApp" and + "Desktop". + :paramtype application_type: str or ~azure.mgmt.desktopvirtualization.models.ApplicationType + :keyword session_state: State of user session. Known values are: "Unknown", "Active", + "Disconnected", "Pending", "LogOff", and "UserProfileDiskMounted". + :paramtype session_state: str or ~azure.mgmt.desktopvirtualization.models.SessionState + :keyword active_directory_user_name: The active directory user name. + :paramtype active_directory_user_name: str + :keyword create_time: The timestamp of the user session create. + :paramtype create_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.system_data = None self.object_id = None self.user_principal_name = user_principal_name @@ -3248,38 +4176,37 @@ def __init__( self.create_time = create_time -class UserSessionList(msrest.serialization.Model): +class UserSessionList(_serialization.Model): """List of UserSession definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of UserSession definitions. - :type value: list[~desktop_virtualization_api_client.models.UserSession] + :ivar value: List of UserSession definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.UserSession] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[UserSession]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[UserSession]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["UserSession"]] = None, - **kwargs - ): - super(UserSessionList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.UserSession"]] = None, **kwargs): + """ + :keyword value: List of UserSession definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.UserSession] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class Workspace(ResourceModelWithAllowedPropertySet): +class Workspace(ResourceModelWithAllowedPropertySet): # pylint: disable=too-many-instance-attributes """Represents a Workspace definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -3292,81 +4219,75 @@ class Workspace(ResourceModelWithAllowedPropertySet): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param location: The geo-location where the resource lives. - :type location: str - :param managed_by: The fully qualified resource ID of the resource that manages this resource. + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar managed_by: The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. - :type managed_by: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :vartype managed_by: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar etag: The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. :vartype etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: - :type identity: - ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetIdentity - :param sku: - :type sku: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetSku - :param plan: - :type plan: ~desktop_virtualization_api_client.models.ResourceModelWithAllowedPropertySetPlan + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: + :vartype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :ivar sku: + :vartype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :ivar plan: + :vartype plan: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~desktop_virtualization_api_client.models.SystemData + :vartype system_data: ~azure.mgmt.desktopvirtualization.models.SystemData :ivar object_id: ObjectId of Workspace. (internal use). :vartype object_id: str - :param description: Description of Workspace. - :type description: str - :param friendly_name: Friendly name of Workspace. - :type friendly_name: str - :param application_group_references: List of applicationGroup resource Ids. - :type application_group_references: list[str] + :ivar description: Description of Workspace. + :vartype description: str + :ivar friendly_name: Friendly name of Workspace. + :vartype friendly_name: str + :ivar application_group_references: List of applicationGroup resource Ids. + :vartype application_group_references: list[str] :ivar cloud_pc_resource: Is cloud pc resource. :vartype cloud_pc_resource: bool - :param public_network_access: Enabled allows this resource to be accessed from both public and - private networks, Disabled allows this resource to only be accessed via private endpoints. - Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~desktop_virtualization_api_client.models.PublicNetworkAccess """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'object_id': {'readonly': True}, - 'cloud_pc_resource': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceModelWithAllowedPropertySetIdentity'}, - 'sku': {'key': 'sku', 'type': 'ResourceModelWithAllowedPropertySetSku'}, - 'plan': {'key': 'plan', 'type': 'ResourceModelWithAllowedPropertySetPlan'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'application_group_references': {'key': 'properties.applicationGroupReferences', 'type': '[str]'}, - 'cloud_pc_resource': {'key': 'properties.cloudPcResource', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "object_id": {"readonly": True}, + "cloud_pc_resource": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceModelWithAllowedPropertySetIdentity"}, + "sku": {"key": "sku", "type": "ResourceModelWithAllowedPropertySetSku"}, + "plan": {"key": "plan", "type": "ResourceModelWithAllowedPropertySetPlan"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "application_group_references": {"key": "properties.applicationGroupReferences", "type": "[str]"}, + "cloud_pc_resource": {"key": "properties.cloudPcResource", "type": "bool"}, } def __init__( @@ -3376,79 +4297,109 @@ def __init__( managed_by: Optional[str] = None, kind: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceModelWithAllowedPropertySetIdentity"] = None, - sku: Optional["ResourceModelWithAllowedPropertySetSku"] = None, - plan: Optional["ResourceModelWithAllowedPropertySetPlan"] = None, + identity: Optional["_models.ResourceModelWithAllowedPropertySetIdentity"] = None, + sku: Optional["_models.ResourceModelWithAllowedPropertySetSku"] = None, + plan: Optional["_models.ResourceModelWithAllowedPropertySetPlan"] = None, description: Optional[str] = None, friendly_name: Optional[str] = None, application_group_references: Optional[List[str]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, **kwargs ): - super(Workspace, self).__init__(location=location, managed_by=managed_by, kind=kind, tags=tags, identity=identity, sku=sku, plan=plan, **kwargs) + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword managed_by: The fully qualified resource ID of the resource that manages this + resource. Indicates if this resource is managed by another Azure resource. If this is present, + complete mode deployment will not delete the resource if it is removed from the template since + it is managed by another resource. + :paramtype managed_by: str + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: + :paramtype identity: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetIdentity + :keyword sku: + :paramtype sku: ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetSku + :keyword plan: + :paramtype plan: + ~azure.mgmt.desktopvirtualization.models.ResourceModelWithAllowedPropertySetPlan + :keyword description: Description of Workspace. + :paramtype description: str + :keyword friendly_name: Friendly name of Workspace. + :paramtype friendly_name: str + :keyword application_group_references: List of applicationGroup resource Ids. + :paramtype application_group_references: list[str] + """ + super().__init__( + location=location, + managed_by=managed_by, + kind=kind, + tags=tags, + identity=identity, + sku=sku, + plan=plan, + **kwargs + ) self.system_data = None self.object_id = None self.description = description self.friendly_name = friendly_name self.application_group_references = application_group_references self.cloud_pc_resource = None - self.public_network_access = public_network_access -class WorkspaceList(msrest.serialization.Model): +class WorkspaceList(_serialization.Model): """List of Workspace definitions. Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Workspace definitions. - :type value: list[~desktop_virtualization_api_client.models.Workspace] + :ivar value: List of Workspace definitions. + :vartype value: list[~azure.mgmt.desktopvirtualization.models.Workspace] :ivar next_link: Link to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Workspace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Workspace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Workspace"]] = None, - **kwargs - ): - super(WorkspaceList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.Workspace"]] = None, **kwargs): + """ + :keyword value: List of Workspace definitions. + :paramtype value: list[~azure.mgmt.desktopvirtualization.models.Workspace] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class WorkspacePatch(msrest.serialization.Model): +class WorkspacePatch(_serialization.Model): """Workspace properties that can be patched. - :param tags: A set of tags. tags to be updated. - :type tags: dict[str, str] - :param description: Description of Workspace. - :type description: str - :param friendly_name: Friendly name of Workspace. - :type friendly_name: str - :param application_group_references: List of applicationGroup links. - :type application_group_references: list[str] - :param public_network_access: Enabled to allow this resource to be access from the public - network. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~desktop_virtualization_api_client.models.PublicNetworkAccess + :ivar tags: tags to be updated. + :vartype tags: dict[str, str] + :ivar description: Description of Workspace. + :vartype description: str + :ivar friendly_name: Friendly name of Workspace. + :vartype friendly_name: str + :ivar application_group_references: List of applicationGroup links. + :vartype application_group_references: list[str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'application_group_references': {'key': 'properties.applicationGroupReferences', 'type': '[str]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "application_group_references": {"key": "properties.applicationGroupReferences", "type": "[str]"}, } def __init__( @@ -3458,12 +4409,20 @@ def __init__( description: Optional[str] = None, friendly_name: Optional[str] = None, application_group_references: Optional[List[str]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, **kwargs ): - super(WorkspacePatch, self).__init__(**kwargs) + """ + :keyword tags: tags to be updated. + :paramtype tags: dict[str, str] + :keyword description: Description of Workspace. + :paramtype description: str + :keyword friendly_name: Friendly name of Workspace. + :paramtype friendly_name: str + :keyword application_group_references: List of applicationGroup links. + :paramtype application_group_references: list[str] + """ + super().__init__(**kwargs) self.tags = tags self.description = description self.friendly_name = friendly_name self.application_group_references = application_group_references - self.public_network_access = public_network_access diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_patch.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/__init__.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/__init__.py index 63576d0654da..432b50de74a4 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/__init__.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/__init__.py @@ -9,6 +9,7 @@ from ._operations import Operations from ._workspaces_operations import WorkspacesOperations from ._scaling_plans_operations import ScalingPlansOperations +from ._scaling_plan_pooled_schedules_operations import ScalingPlanPooledSchedulesOperations from ._application_groups_operations import ApplicationGroupsOperations from ._start_menu_items_operations import StartMenuItemsOperations from ._applications_operations import ApplicationsOperations @@ -18,22 +19,25 @@ from ._session_hosts_operations import SessionHostsOperations from ._msix_packages_operations import MSIXPackagesOperations from ._msix_images_operations import MsixImagesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Operations', - 'WorkspacesOperations', - 'ScalingPlansOperations', - 'ApplicationGroupsOperations', - 'StartMenuItemsOperations', - 'ApplicationsOperations', - 'DesktopsOperations', - 'HostPoolsOperations', - 'UserSessionsOperations', - 'SessionHostsOperations', - 'MSIXPackagesOperations', - 'MsixImagesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', + "Operations", + "WorkspacesOperations", + "ScalingPlansOperations", + "ScalingPlanPooledSchedulesOperations", + "ApplicationGroupsOperations", + "StartMenuItemsOperations", + "ApplicationsOperations", + "DesktopsOperations", + "HostPoolsOperations", + "UserSessionsOperations", + "SessionHostsOperations", + "MSIXPackagesOperations", + "MsixImagesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_application_groups_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_application_groups_operations.py index 35d423413cb7..e2d683c29611 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_application_groups_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_application_groups_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,158 +6,470 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, application_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, application_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, application_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, application_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request( + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/applicationGroups" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApplicationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ApplicationGroupsOperations(object): - """ApplicationGroupsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`application_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def get( - self, - resource_group_name, # type: str - application_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationGroup" + @distributed_trace + def get(self, resource_group_name: str, application_group_name: str, **kwargs: Any) -> _models.ApplicationGroup: """Get an application group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationGroup, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ApplicationGroup - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroup] + + request = build_get_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('ApplicationGroup', pipeline_response) + deserialized = self._deserialize("ApplicationGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + application_group_name: str, + application_group: _models.ApplicationGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationGroup: + """Create or update an applicationGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_group: Object containing ApplicationGroup definitions. Required. + :type application_group: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def create_or_update( self, - resource_group_name, # type: str - application_group_name, # type: str - application_group, # type: "_models.ApplicationGroup" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationGroup" + resource_group_name: str, + application_group_name: str, + application_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationGroup: """Create or update an applicationGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str - :param application_group: Object containing ApplicationGroup definitions. - :type application_group: ~desktop_virtualization_api_client.models.ApplicationGroup + :param application_group: Object containing ApplicationGroup definitions. Required. + :type application_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationGroup, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ApplicationGroup - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + application_group_name: str, + application_group: Union[_models.ApplicationGroup, IO], + **kwargs: Any + ) -> _models.ApplicationGroup: + """Create or update an applicationGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_group: Object containing ApplicationGroup definitions. Is either a model + type or a IO type. Required. + :type application_group: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(application_group, 'ApplicationGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application_group, (IO, bytes)): + _content = application_group + else: + _json = self._serialize.body(application_group, "ApplicationGroup") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -164,62 +477,66 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ApplicationGroup', pipeline_response) + deserialized = self._deserialize("ApplicationGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ApplicationGroup', pipeline_response) + deserialized = self._deserialize("ApplicationGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - application_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_group_name: str, **kwargs: Any + ) -> None: """Remove an applicationGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -229,133 +546,237 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}"} # type: ignore + @overload def update( self, - resource_group_name, # type: str - application_group_name, # type: str - application_group=None, # type: Optional["_models.ApplicationGroupPatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationGroup" + resource_group_name: str, + application_group_name: str, + application_group: Optional[_models.ApplicationGroupPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationGroup: """Update an applicationGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str - :param application_group: Object containing ApplicationGroup definitions. - :type application_group: ~desktop_virtualization_api_client.models.ApplicationGroupPatch + :param application_group: Object containing ApplicationGroup definitions. Default value is + None. + :type application_group: ~azure.mgmt.desktopvirtualization.models.ApplicationGroupPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationGroup, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ApplicationGroup - :raises: ~azure.core.exceptions.HttpResponseError + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + def update( + self, + resource_group_name: str, + application_group_name: str, + application_group: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationGroup: + """Update an applicationGroup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_group: Object containing ApplicationGroup definitions. Default value is + None. + :type application_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ - # 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') + @distributed_trace + def update( + self, + resource_group_name: str, + application_group_name: str, + application_group: Optional[Union[_models.ApplicationGroupPatch, IO]] = None, + **kwargs: Any + ) -> _models.ApplicationGroup: + """Update an applicationGroup. - body_content_kwargs = {} # type: Dict[str, Any] - if application_group is not None: - body_content = self._serialize.body(application_group, 'ApplicationGroupPatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_group: Object containing ApplicationGroup definitions. Is either a model + type or a IO type. Default value is None. + :type application_group: ~azure.mgmt.desktopvirtualization.models.ApplicationGroupPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationGroup or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ApplicationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application_group, (IO, bytes)): + _content = application_group else: - body_content = None - 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) + if application_group is not None: + _json = self._serialize.body(application_group, "ApplicationGroupPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ApplicationGroup', pipeline_response) + deserialized = self._deserialize("ApplicationGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationGroupList"] + resource_group_name: str, + filter: Optional[str] = None, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApplicationGroup"]: """List applicationGroups. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param filter: OData filter expression. Valid properties for filtering are - applicationGroupType. + applicationGroupType. Default value is None. :type filter: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.ApplicationGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ApplicationGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ApplicationGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroupList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroupList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationGroupList', pipeline_response) + deserialized = self._deserialize("ApplicationGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -364,7 +785,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -373,62 +796,72 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups'} # type: ignore + return ItemPaged(get_next, extract_data) - def list_by_subscription( - self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationGroupList"] + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups"} # type: ignore + + @distributed_trace + def list_by_subscription(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.ApplicationGroup"]: """List applicationGroups in subscription. :param filter: OData filter expression. Valid properties for filtering are - applicationGroupType. + applicationGroupType. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.ApplicationGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ApplicationGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ApplicationGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationGroupList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationGroupList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationGroupList', pipeline_response) + deserialized = self._deserialize("ApplicationGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,7 +870,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -446,7 +881,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/applicationGroups'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/applicationGroups"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_applications_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_applications_operations.py index 59dd6449ed15..4e54412ea092 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_applications_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_applications_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,166 +6,464 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, application_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=24, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, application_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=24, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, application_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=24, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, application_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=24, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + application_group_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ApplicationsOperations(object): - """ApplicationsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( - self, - resource_group_name, # type: str - application_group_name, # type: str - application_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Application" + self, resource_group_name: str, application_group_name: str, application_name: str, **kwargs: Any + ) -> _models.Application: """Get an application. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :param application_name: The name of the application within the specified application group. + Required. :type application_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Application - :raises: ~azure.core.exceptions.HttpResponseError + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=24, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + request = build_get_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + application_group_name: str, + application_name: str, + application: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Create or update an application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_name: The name of the application within the specified application group. + Required. + :type application_name: str + :param application: Object containing Application definitions. Required. + :type application: ~azure.mgmt.desktopvirtualization.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + application_group_name: str, + application_name: str, + application: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Create or update an application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_name: The name of the application within the specified application group. + Required. + :type application_name: str + :param application: Object containing Application definitions. Required. + :type application: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - application_group_name, # type: str - application_name, # type: str - application, # type: "_models.Application" - **kwargs # type: Any - ): - # type: (...) -> "_models.Application" + resource_group_name: str, + application_group_name: str, + application_name: str, + application: Union[_models.Application, IO], + **kwargs: Any + ) -> _models.Application: """Create or update an application. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :param application_name: The name of the application within the specified application group. + Required. :type application_name: str - :param application: Object containing Application definitions. - :type application: ~desktop_virtualization_api_client.models.Application + :param application: Object containing Application definitions. Is either a model type or a IO + type. Required. + :type application: ~azure.mgmt.desktopvirtualization.models.Application or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Application - :raises: ~azure.core.exceptions.HttpResponseError + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(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(application, 'Application') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application, (IO, bytes)): + _content = application + else: + _json = self._serialize.body(application, "Application") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -172,66 +471,70 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - application_group_name, # type: str - application_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_group_name: str, application_name: str, **kwargs: Any + ) -> None: """Remove an application. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :param application_name: The name of the application within the specified application group. + Required. :type application_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -241,135 +544,247 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}"} # type: ignore + @overload def update( self, - resource_group_name, # type: str - application_group_name, # type: str - application_name, # type: str - application=None, # type: Optional["_models.ApplicationPatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Application" + resource_group_name: str, + application_group_name: str, + application_name: str, + application: Optional[_models.ApplicationPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: """Update an application. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str :param application_name: The name of the application within the specified application group. + Required. :type application_name: str - :param application: Object containing Application definitions. - :type application: ~desktop_virtualization_api_client.models.ApplicationPatch + :param application: Object containing Application definitions. Default value is None. + :type application: ~azure.mgmt.desktopvirtualization.models.ApplicationPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Application - :raises: ~azure.core.exceptions.HttpResponseError + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + def update( + self, + resource_group_name: str, + application_group_name: str, + application_name: str, + application: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Update an application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_name: The name of the application within the specified application group. + Required. + :type application_name: str + :param application: Object containing Application definitions. Default value is None. + :type application: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ - # 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') + @distributed_trace + def update( + self, + resource_group_name: str, + application_group_name: str, + application_name: str, + application: Optional[Union[_models.ApplicationPatch, IO]] = None, + **kwargs: Any + ) -> _models.Application: + """Update an application. - body_content_kwargs = {} # type: Dict[str, Any] - if application is not None: - body_content = self._serialize.body(application, 'ApplicationPatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param application_name: The name of the application within the specified application group. + Required. + :type application_name: str + :param application: Object containing Application definitions. Is either a model type or a IO + type. Default value is None. + :type application: ~azure.mgmt.desktopvirtualization.models.ApplicationPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(application, (IO, bytes)): + _content = application else: - body_content = None - 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) + if application is not None: + _json = self._serialize.body(application, "ApplicationPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications/{applicationName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - application_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationList"] + resource_group_name: str, + application_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.Application"]: """List applications. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.ApplicationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationList', pipeline_response) + deserialized = self._deserialize("ApplicationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -378,7 +793,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -387,7 +804,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/applications"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_desktops_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_desktops_operations.py index 2a315452e564..5c1162ededf8 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_desktops_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_desktops_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,236 +6,485 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, application_group_name: str, desktop_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + "desktopName": _SERIALIZER.url("desktop_name", desktop_name, "str", max_length=24, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, application_group_name: str, desktop_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + "desktopName": _SERIALIZER.url("desktop_name", desktop_name, "str", max_length=24, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + application_group_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DesktopsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DesktopsOperations(object): - """DesktopsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`desktops` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( - self, - resource_group_name, # type: str - application_group_name, # type: str - desktop_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Desktop" + self, resource_group_name: str, application_group_name: str, desktop_name: str, **kwargs: Any + ) -> _models.Desktop: """Get a desktop. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str - :param desktop_name: The name of the desktop within the specified desktop group. + :param desktop_name: The name of the desktop within the specified desktop group. Required. :type desktop_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Desktop, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Desktop - :raises: ~azure.core.exceptions.HttpResponseError + :return: Desktop or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Desktop + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Desktop"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'desktopName': self._serialize.url("desktop_name", desktop_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Desktop] + + request = build_get_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + desktop_name=desktop_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('Desktop', pipeline_response) + deserialized = self._deserialize("Desktop", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}"} # type: ignore + + @overload def update( self, - resource_group_name, # type: str - application_group_name, # type: str - desktop_name, # type: str - desktop=None, # type: Optional["_models.DesktopPatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Desktop" + resource_group_name: str, + application_group_name: str, + desktop_name: str, + desktop: Optional[_models.DesktopPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Desktop: """Update a desktop. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str - :param desktop_name: The name of the desktop within the specified desktop group. + :param desktop_name: The name of the desktop within the specified desktop group. Required. :type desktop_name: str - :param desktop: Object containing Desktop definitions. - :type desktop: ~desktop_virtualization_api_client.models.DesktopPatch + :param desktop: Object containing Desktop definitions. Default value is None. + :type desktop: ~azure.mgmt.desktopvirtualization.models.DesktopPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Desktop, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Desktop - :raises: ~azure.core.exceptions.HttpResponseError + :return: Desktop or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Desktop + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Desktop"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - 'desktopName': self._serialize.url("desktop_name", desktop_name, 'str', max_length=24, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + def update( + self, + resource_group_name: str, + application_group_name: str, + desktop_name: str, + desktop: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Desktop: + """Update a desktop. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param desktop_name: The name of the desktop within the specified desktop group. Required. + :type desktop_name: str + :param desktop: Object containing Desktop definitions. Default value is None. + :type desktop: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Desktop or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Desktop + :raises ~azure.core.exceptions.HttpResponseError: + """ - body_content_kwargs = {} # type: Dict[str, Any] - if desktop is not None: - body_content = self._serialize.body(desktop, 'DesktopPatch') + @distributed_trace + def update( + self, + resource_group_name: str, + application_group_name: str, + desktop_name: str, + desktop: Optional[Union[_models.DesktopPatch, IO]] = None, + **kwargs: Any + ) -> _models.Desktop: + """Update a desktop. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_group_name: The name of the application group. Required. + :type application_group_name: str + :param desktop_name: The name of the desktop within the specified desktop group. Required. + :type desktop_name: str + :param desktop: Object containing Desktop definitions. Is either a model type or a IO type. + Default value is None. + :type desktop: ~azure.mgmt.desktopvirtualization.models.DesktopPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Desktop or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Desktop + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Desktop] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(desktop, (IO, bytes)): + _content = desktop else: - body_content = None - 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) + if desktop is not None: + _json = self._serialize.body(desktop, "DesktopPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + desktop_name=desktop_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Desktop', pipeline_response) + deserialized = self._deserialize("Desktop", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops/{desktopName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - application_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DesktopList"] + resource_group_name: str, + application_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.Desktop"]: """List desktops. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DesktopList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.DesktopList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Desktop or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.Desktop] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DesktopList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DesktopList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DesktopList', pipeline_response) + deserialized = self._deserialize("DesktopList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -243,7 +493,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +504,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/desktops"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_host_pools_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_host_pools_operations.py index 12f946b4b400..8fe453b5ba90 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_host_pools_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_host_pools_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,158 +6,499 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, host_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, host_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, host_pool_name: str, subscription_id: str, *, force: Optional[bool] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, host_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/hostPools" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_retrieve_registration_token_request( + resource_group_name: str, host_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/retrieveRegistrationToken", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class HostPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class HostPoolsOperations(object): - """HostPoolsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`host_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def get( - self, - resource_group_name, # type: str - host_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.HostPool" + @distributed_trace + def get(self, resource_group_name: str, host_pool_name: str, **kwargs: Any) -> _models.HostPool: """Get a host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HostPool, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.HostPool - :raises: ~azure.core.exceptions.HttpResponseError + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPool] + + request = build_get_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('HostPool', pipeline_response) + deserialized = self._deserialize("HostPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}"} # type: ignore + + @overload def create_or_update( self, - resource_group_name, # type: str - host_pool_name, # type: str - host_pool, # type: "_models.HostPool" - **kwargs # type: Any - ): - # type: (...) -> "_models.HostPool" + resource_group_name: str, + host_pool_name: str, + host_pool: _models.HostPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HostPool: + """Create or update a host pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param host_pool: Object containing HostPool definitions. Required. + :type host_pool: ~azure.mgmt.desktopvirtualization.models.HostPool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + host_pool_name: str, + host_pool: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HostPool: + """Create or update a host pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param host_pool: Object containing HostPool definitions. Required. + :type host_pool: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, host_pool_name: str, host_pool: Union[_models.HostPool, IO], **kwargs: Any + ) -> _models.HostPool: """Create or update a host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str - :param host_pool: Object containing HostPool definitions. - :type host_pool: ~desktop_virtualization_api_client.models.HostPool + :param host_pool: Object containing HostPool definitions. Is either a model type or a IO type. + Required. + :type host_pool: ~azure.mgmt.desktopvirtualization.models.HostPool or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HostPool, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.HostPool - :raises: ~azure.core.exceptions.HttpResponseError + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(host_pool, 'HostPool') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPool] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(host_pool, (IO, bytes)): + _content = host_pool + else: + _json = self._serialize.body(host_pool, "HostPool") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -164,67 +506,69 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('HostPool', pipeline_response) + deserialized = self._deserialize("HostPool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('HostPool', pipeline_response) + deserialized = self._deserialize("HostPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - host_pool_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, host_pool_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> None: """Remove a host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str - :param force: Force flag to delete sessionHost. + :param force: Force flag to delete sessionHost. Default value is None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -234,127 +578,230 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}"} # type: ignore + @overload def update( self, - resource_group_name, # type: str - host_pool_name, # type: str - host_pool=None, # type: Optional["_models.HostPoolPatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.HostPool" + resource_group_name: str, + host_pool_name: str, + host_pool: Optional[_models.HostPoolPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HostPool: """Update a host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str - :param host_pool: Object containing HostPool definitions. - :type host_pool: ~desktop_virtualization_api_client.models.HostPoolPatch + :param host_pool: Object containing HostPool definitions. Default value is None. + :type host_pool: ~azure.mgmt.desktopvirtualization.models.HostPoolPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HostPool, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.HostPool - :raises: ~azure.core.exceptions.HttpResponseError + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPool"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + def update( + self, + resource_group_name: str, + host_pool_name: str, + host_pool: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HostPool: + """Update a host pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param host_pool: Object containing HostPool definitions. Default value is None. + :type host_pool: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: + """ - # 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') + @distributed_trace + def update( + self, + resource_group_name: str, + host_pool_name: str, + host_pool: Optional[Union[_models.HostPoolPatch, IO]] = None, + **kwargs: Any + ) -> _models.HostPool: + """Update a host pool. - body_content_kwargs = {} # type: Dict[str, Any] - if host_pool is not None: - body_content = self._serialize.body(host_pool, 'HostPoolPatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param host_pool: Object containing HostPool definitions. Is either a model type or a IO type. + Default value is None. + :type host_pool: ~azure.mgmt.desktopvirtualization.models.HostPoolPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HostPool or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.HostPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPool] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(host_pool, (IO, bytes)): + _content = host_pool else: - body_content = None - 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) + if host_pool is not None: + _json = self._serialize.body(host_pool, "HostPoolPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('HostPool', pipeline_response) + deserialized = self._deserialize("HostPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HostPoolList"] + resource_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.HostPool"]: """List hostPools. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HostPoolList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.HostPoolList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either HostPool or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.HostPool] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPoolList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPoolList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('HostPoolList', pipeline_response) + deserialized = self._deserialize("HostPoolList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -363,7 +810,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -372,56 +821,83 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools"} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HostPoolList"] + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.HostPool"]: """List hostPools in subscription. + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HostPoolList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.HostPoolList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either HostPool or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.HostPool] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostPoolList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostPoolList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('HostPoolList', pipeline_response) + deserialized = self._deserialize("HostPoolList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -430,7 +906,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -439,66 +917,69 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/hostPools'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/hostPools"} # type: ignore + @distributed_trace def retrieve_registration_token( - self, - resource_group_name, # type: str - host_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistrationInfo" + self, resource_group_name: str, host_pool_name: str, **kwargs: Any + ) -> _models.RegistrationInfo: """Registration token of the host pool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistrationInfo, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.RegistrationInfo - :raises: ~azure.core.exceptions.HttpResponseError + :return: RegistrationInfo or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.RegistrationInfo + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.retrieve_registration_token.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RegistrationInfo] + + request = build_retrieve_registration_token_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.retrieve_registration_token.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('RegistrationInfo', pipeline_response) + deserialized = self._deserialize("RegistrationInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - retrieve_registration_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/retrieveRegistrationToken'} # type: ignore + + retrieve_registration_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/retrieveRegistrationToken"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_msix_images_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_msix_images_operations.py index 4b3888285aae..53cc5df5795c 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_msix_images_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_msix_images_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,240 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class MsixImagesOperations(object): - """MsixImagesOperations 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. +def build_expand_request( + resource_group_name: str, host_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/expandMsixImage", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class MsixImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`msix_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload def expand( self, - resource_group_name, # type: str - host_pool_name, # type: str - msix_image_uri, # type: "_models.MSIXImageURI" - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ExpandMsixImageList"] + resource_group_name: str, + host_pool_name: str, + msix_image_uri: _models.MSIXImageURI, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Iterable["_models.ExpandMsixImage"]: """Expands and Lists MSIX packages in an Image, given the Image Path. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str - :param msix_image_uri: Object containing URI to MSIX Image. - :type msix_image_uri: ~desktop_virtualization_api_client.models.MSIXImageURI + :param msix_image_uri: Object containing URI to MSIX Image. Required. + :type msix_image_uri: ~azure.mgmt.desktopvirtualization.models.MSIXImageURI + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExpandMsixImageList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.ExpandMsixImageList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ExpandMsixImage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ExpandMsixImage] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpandMsixImageList"] + + @overload + def expand( + self, + resource_group_name: str, + host_pool_name: str, + msix_image_uri: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Iterable["_models.ExpandMsixImage"]: + """Expands and Lists MSIX packages in an Image, given the Image Path. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_image_uri: Object containing URI to MSIX Image. Required. + :type msix_image_uri: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExpandMsixImage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ExpandMsixImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def expand( + self, + resource_group_name: str, + host_pool_name: str, + msix_image_uri: Union[_models.MSIXImageURI, IO], + **kwargs: Any + ) -> Iterable["_models.ExpandMsixImage"]: + """Expands and Lists MSIX packages in an Image, given the Image Path. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_image_uri: Object containing URI to MSIX Image. Is either a model type or a IO + type. Required. + :type msix_image_uri: ~azure.mgmt.desktopvirtualization.models.MSIXImageURI or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExpandMsixImage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ExpandMsixImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExpandMsixImageList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - content_type = "application/json" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(msix_image_uri, (IO, bytes)): + _content = msix_image_uri + else: + _json = self._serialize.body(msix_image_uri, "MSIXImageURI") def prepare_request(next_link=None): - # 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') - if not next_link: - # Construct URL - url = self.expand.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(msix_image_uri, 'MSIXImageURI') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + request = build_expand_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.expand.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(msix_image_uri, 'MSIXImageURI') - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ExpandMsixImageList', pipeline_response) + deserialized = self._deserialize("ExpandMsixImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,7 +248,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -126,7 +259,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - expand.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/expandMsixImage'} # type: ignore + return ItemPaged(get_next, extract_data) + + expand.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/expandMsixImage"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_msix_packages_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_msix_packages_operations.py index 140e1fe0cf52..ece5453a6922 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_msix_packages_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_msix_packages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,168 +6,462 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, host_pool_name: str, msix_package_full_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "msixPackageFullName": _SERIALIZER.url( + "msix_package_full_name", msix_package_full_name, "str", max_length=100, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, host_pool_name: str, msix_package_full_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "msixPackageFullName": _SERIALIZER.url( + "msix_package_full_name", msix_package_full_name, "str", max_length=100, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, host_pool_name: str, msix_package_full_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "msixPackageFullName": _SERIALIZER.url( + "msix_package_full_name", msix_package_full_name, "str", max_length=100, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, host_pool_name: str, msix_package_full_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "msixPackageFullName": _SERIALIZER.url( + "msix_package_full_name", msix_package_full_name, "str", max_length=100, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + host_pool_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class MSIXPackagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class MSIXPackagesOperations(object): - """MSIXPackagesOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`msix_packages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( - self, - resource_group_name, # type: str - host_pool_name, # type: str - msix_package_full_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MSIXPackage" + self, resource_group_name: str, host_pool_name: str, msix_package_full_name: str, **kwargs: Any + ) -> _models.MSIXPackage: """Get a msixpackage. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param msix_package_full_name: The version specific package full name of the MSIX package - within specified hostpool. + within specified hostpool. Required. :type msix_package_full_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MSIXPackage, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.MSIXPackage - :raises: ~azure.core.exceptions.HttpResponseError + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MSIXPackage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'msixPackageFullName': self._serialize.url("msix_package_full_name", msix_package_full_name, 'str', max_length=100, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MSIXPackage] + + request = build_get_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + msix_package_full_name=msix_package_full_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('MSIXPackage', pipeline_response) + deserialized = self._deserialize("MSIXPackage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: _models.MSIXPackage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MSIXPackage: + """Create or update a MSIX package. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_package_full_name: The version specific package full name of the MSIX package + within specified hostpool. Required. + :type msix_package_full_name: str + :param msix_package: Object containing MSIX Package definitions. Required. + :type msix_package: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MSIXPackage: + """Create or update a MSIX package. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_package_full_name: The version specific package full name of the MSIX package + within specified hostpool. Required. + :type msix_package_full_name: str + :param msix_package: Object containing MSIX Package definitions. Required. + :type msix_package: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - host_pool_name, # type: str - msix_package_full_name, # type: str - msix_package, # type: "_models.MSIXPackage" - **kwargs # type: Any - ): - # type: (...) -> "_models.MSIXPackage" + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: Union[_models.MSIXPackage, IO], + **kwargs: Any + ) -> _models.MSIXPackage: """Create or update a MSIX package. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param msix_package_full_name: The version specific package full name of the MSIX package - within specified hostpool. + within specified hostpool. Required. :type msix_package_full_name: str - :param msix_package: Object containing MSIX Package definitions. - :type msix_package: ~desktop_virtualization_api_client.models.MSIXPackage + :param msix_package: Object containing MSIX Package definitions. Is either a model type or a + IO type. Required. + :type msix_package: ~azure.mgmt.desktopvirtualization.models.MSIXPackage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MSIXPackage, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.MSIXPackage - :raises: ~azure.core.exceptions.HttpResponseError + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MSIXPackage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'msixPackageFullName': self._serialize.url("msix_package_full_name", msix_package_full_name, 'str', max_length=100, min_length=3), - } - url = self._client.format_url(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(msix_package, 'MSIXPackage') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MSIXPackage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(msix_package, (IO, bytes)): + _content = msix_package + else: + _json = self._serialize.body(msix_package, "MSIXPackage") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + msix_package_full_name=msix_package_full_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -174,67 +469,70 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MSIXPackage', pipeline_response) + deserialized = self._deserialize("MSIXPackage", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('MSIXPackage', pipeline_response) + deserialized = self._deserialize("MSIXPackage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - host_pool_name, # type: str - msix_package_full_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, host_pool_name: str, msix_package_full_name: str, **kwargs: Any + ) -> None: """Remove an MSIX Package. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param msix_package_full_name: The version specific package full name of the MSIX package - within specified hostpool. + within specified hostpool. Required. :type msix_package_full_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'msixPackageFullName': self._serialize.url("msix_package_full_name", msix_package_full_name, 'str', max_length=100, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + msix_package_full_name=msix_package_full_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -244,136 +542,247 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}"} # type: ignore + @overload def update( self, - resource_group_name, # type: str - host_pool_name, # type: str - msix_package_full_name, # type: str - msix_package=None, # type: Optional["_models.MSIXPackagePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.MSIXPackage" + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: Optional[_models.MSIXPackagePatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MSIXPackage: """Update an MSIX Package. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param msix_package_full_name: The version specific package full name of the MSIX package - within specified hostpool. + within specified hostpool. Required. :type msix_package_full_name: str - :param msix_package: Object containing MSIX Package definitions. - :type msix_package: ~desktop_virtualization_api_client.models.MSIXPackagePatch + :param msix_package: Object containing MSIX Package definitions. Default value is None. + :type msix_package: ~azure.mgmt.desktopvirtualization.models.MSIXPackagePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MSIXPackage, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.MSIXPackage - :raises: ~azure.core.exceptions.HttpResponseError + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MSIXPackage"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'msixPackageFullName': self._serialize.url("msix_package_full_name", msix_package_full_name, 'str', max_length=100, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + def update( + self, + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MSIXPackage: + """Update an MSIX Package. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_package_full_name: The version specific package full name of the MSIX package + within specified hostpool. Required. + :type msix_package_full_name: str + :param msix_package: Object containing MSIX Package definitions. Default value is None. + :type msix_package: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ - # 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') + @distributed_trace + def update( + self, + resource_group_name: str, + host_pool_name: str, + msix_package_full_name: str, + msix_package: Optional[Union[_models.MSIXPackagePatch, IO]] = None, + **kwargs: Any + ) -> _models.MSIXPackage: + """Update an MSIX Package. - body_content_kwargs = {} # type: Dict[str, Any] - if msix_package is not None: - body_content = self._serialize.body(msix_package, 'MSIXPackagePatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param msix_package_full_name: The version specific package full name of the MSIX package + within specified hostpool. Required. + :type msix_package_full_name: str + :param msix_package: Object containing MSIX Package definitions. Is either a model type or a IO + type. Default value is None. + :type msix_package: ~azure.mgmt.desktopvirtualization.models.MSIXPackagePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MSIXPackage or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.MSIXPackage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MSIXPackage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(msix_package, (IO, bytes)): + _content = msix_package else: - body_content = None - 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) + if msix_package is not None: + _json = self._serialize.body(msix_package, "MSIXPackagePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + msix_package_full_name=msix_package_full_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MSIXPackage', pipeline_response) + deserialized = self._deserialize("MSIXPackage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages/{msixPackageFullName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - host_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MSIXPackageList"] + resource_group_name: str, + host_pool_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.MSIXPackage"]: """List MSIX packages in hostpool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MSIXPackageList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.MSIXPackageList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MSIXPackage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.MSIXPackage] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MSIXPackageList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MSIXPackageList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MSIXPackageList', pipeline_response) + deserialized = self._deserialize("MSIXPackageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -382,7 +791,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,7 +802,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/msixPackages"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_operations.py index 0438e92acc25..f6636713d6a8 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,138 @@ # 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 +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DesktopVirtualization/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. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceProviderOperationList"] + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all of the available operations the Desktop Virtualization resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceProviderOperation or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceProviderOperationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,7 +146,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +157,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DesktopVirtualization/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DesktopVirtualization/operations"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_patch.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_private_endpoint_connections_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index cdb369a42e1e..000000000000 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,590 +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 PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_host_pool( - self, - resource_group_name, # type: str - host_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResultWithSystemData"] - """List private endpoint connections associated with hostpool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResultWithSystemData or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.PrivateEndpointConnectionListResultWithSystemData] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResultWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - 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('PrivateEndpointConnectionListResultWithSystemData', 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_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateEndpointConnections'} # type: ignore - - def get_by_host_pool( - self, - resource_group_name, # type: str - host_pool_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnectionWithSystemData" - """Get a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionWithSystemData, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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('PrivateEndpointConnectionWithSystemData', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - def delete_by_host_pool( - self, - resource_group_name, # type: str - host_pool_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Remove a connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_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 = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - def update_by_host_pool( - self, - resource_group_name, # type: str - host_pool_name, # type: str - private_endpoint_connection_name, # type: str - connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnectionWithSystemData" - """Approve or reject a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_name: str - :param connection: Object containing the updated connection. - :type connection: ~desktop_virtualization_api_client.models.PrivateEndpointConnection - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionWithSystemData, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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(connection, 'PrivateEndpointConnection') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('PrivateEndpointConnectionWithSystemData', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - def list_by_workspace( - self, - resource_group_name, # type: str - workspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResultWithSystemData"] - """List private endpoint connections. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResultWithSystemData or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.PrivateEndpointConnectionListResultWithSystemData] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResultWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - 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('PrivateEndpointConnectionListResultWithSystemData', 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_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateEndpointConnections'} # type: ignore - - def get_by_workspace( - self, - resource_group_name, # type: str - workspace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnectionWithSystemData" - """Get a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionWithSystemData, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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('PrivateEndpointConnectionWithSystemData', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - def delete_by_workspace( - self, - resource_group_name, # type: str - workspace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Remove a connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_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 = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - def update_by_workspace( - self, - resource_group_name, # type: str - workspace_name, # type: str - private_endpoint_connection_name, # type: str - connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnectionWithSystemData" - """Approve or reject a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. - :type private_endpoint_connection_name: str - :param connection: Object containing the updated connection. - :type connection: ~desktop_virtualization_api_client.models.PrivateEndpointConnection - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionWithSystemData, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.PrivateEndpointConnectionWithSystemData - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionWithSystemData"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_by_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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(connection, 'PrivateEndpointConnection') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('PrivateEndpointConnectionWithSystemData', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_private_link_resources_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_private_link_resources_operations.py deleted file mode 100644 index 21893ee73489..000000000000 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,196 +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 PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_host_pool( - self, - resource_group_name, # type: str - host_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateLinkResourceListResult"] - """List the private link resources available for this hostpool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. - :type host_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - 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('PrivateLinkResourceListResult', 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_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/privateLinkResources'} # type: ignore - - def list_by_workspace( - self, - resource_group_name, # type: str - workspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateLinkResourceListResult"] - """List the private link resources available for this workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param workspace_name: The name of the workspace. - :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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_workspace.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - 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('PrivateLinkResourceListResult', 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_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}/privateLinkResources'} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_scaling_plan_pooled_schedules_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_scaling_plan_pooled_schedules_operations.py new file mode 100644 index 000000000000..91774c57450f --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_scaling_plan_pooled_schedules_operations.py @@ -0,0 +1,824 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + "scalingPlanScheduleName": _SERIALIZER.url( + "scaling_plan_schedule_name", scaling_plan_schedule_name, "str", max_length=64, min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + "scalingPlanScheduleName": _SERIALIZER.url( + "scaling_plan_schedule_name", scaling_plan_schedule_name, "str", max_length=64, min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + "scalingPlanScheduleName": _SERIALIZER.url( + "scaling_plan_schedule_name", scaling_plan_schedule_name, "str", max_length=64, min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + "scalingPlanScheduleName": _SERIALIZER.url( + "scaling_plan_schedule_name", scaling_plan_schedule_name, "str", max_length=64, min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + scaling_plan_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ScalingPlanPooledSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`scaling_plan_pooled_schedules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, scaling_plan_name: str, scaling_plan_schedule_name: str, **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Get a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanPooledSchedule] + + request = build_get_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + scaling_plan_schedule_name=scaling_plan_schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScalingPlanPooledSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}"} # type: ignore + + @overload + def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: _models.ScalingPlanPooledSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Create or update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. + Required. + :type scaling_plan_schedule: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Create or update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. + Required. + :type scaling_plan_schedule: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: Union[_models.ScalingPlanPooledSchedule, IO], + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Create or update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. Is + either a model type or a IO type. Required. + :type scaling_plan_schedule: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanPooledSchedule] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scaling_plan_schedule, (IO, bytes)): + _content = scaling_plan_schedule + else: + _json = self._serialize.body(scaling_plan_schedule, "ScalingPlanPooledSchedule") + + request = build_create_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + scaling_plan_schedule_name=scaling_plan_schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ScalingPlanPooledSchedule", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ScalingPlanPooledSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, scaling_plan_name: str, scaling_plan_schedule_name: str, **kwargs: Any + ) -> None: + """Remove a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + scaling_plan_schedule_name=scaling_plan_schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 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.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: Optional[_models.ScalingPlanPooledSchedulePatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. Default + value is None. + :type scaling_plan_schedule: + ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedulePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. Default + value is None. + :type scaling_plan_schedule: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan_schedule_name: str, + scaling_plan_schedule: Optional[Union[_models.ScalingPlanPooledSchedulePatch, IO]] = None, + **kwargs: Any + ) -> _models.ScalingPlanPooledSchedule: + """Update a ScalingPlanPooledSchedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan_schedule_name: The name of the ScalingPlanSchedule. Required. + :type scaling_plan_schedule_name: str + :param scaling_plan_schedule: Object containing ScalingPlanPooledSchedule definitions. Is + either a model type or a IO type. Default value is None. + :type scaling_plan_schedule: + ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedulePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlanPooledSchedule or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanPooledSchedule] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scaling_plan_schedule, (IO, bytes)): + _content = scaling_plan_schedule + else: + if scaling_plan_schedule is not None: + _json = self._serialize.body(scaling_plan_schedule, "ScalingPlanPooledSchedulePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + scaling_plan_schedule_name=scaling_plan_schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScalingPlanPooledSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules/{scalingPlanScheduleName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + scaling_plan_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ScalingPlanPooledSchedule"]: + """List ScalingPlanPooledSchedules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScalingPlanPooledSchedule or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ScalingPlanPooledSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanPooledScheduleList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ScalingPlanPooledScheduleList", 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( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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.DesktopVirtualization/scalingPlans/{scalingPlanName}/pooledSchedules"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_scaling_plans_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_scaling_plans_operations.py index d612336eff64..07ee3ce89edf 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_scaling_plans_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_scaling_plans_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,158 +6,514 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, scaling_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, scaling_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, scaling_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, scaling_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}", + ) # pylint: disable=line-too-long + 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 + ), + "scalingPlanName": _SERIALIZER.url("scaling_plan_name", scaling_plan_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request( + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/scalingPlans" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_host_pool_request( + resource_group_name: str, + host_pool_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/scalingPlans", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ScalingPlansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ScalingPlansOperations(object): - """ScalingPlansOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`scaling_plans` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def get( - self, - resource_group_name, # type: str - scaling_plan_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ScalingPlan" + @distributed_trace + def get(self, resource_group_name: str, scaling_plan_name: str, **kwargs: Any) -> _models.ScalingPlan: """Get a scaling plan. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scaling_plan_name: The name of the scaling plan. + :param scaling_plan_name: The name of the scaling plan. Required. :type scaling_plan_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScalingPlan, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ScalingPlan - :raises: ~azure.core.exceptions.HttpResponseError + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlan"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'scalingPlanName': self._serialize.url("scaling_plan_name", scaling_plan_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlan] + + request = build_get_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('ScalingPlan', pipeline_response) + deserialized = self._deserialize("ScalingPlan", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}"} # type: ignore + + @overload def create( self, - resource_group_name, # type: str - scaling_plan_name, # type: str - scaling_plan, # type: "_models.ScalingPlan" - **kwargs # type: Any - ): - # type: (...) -> "_models.ScalingPlan" + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: _models.ScalingPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlan: """Create or update a scaling plan. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scaling_plan_name: The name of the scaling plan. + :param scaling_plan_name: The name of the scaling plan. Required. :type scaling_plan_name: str - :param scaling_plan: Object containing scaling plan definitions. - :type scaling_plan: ~desktop_virtualization_api_client.models.ScalingPlan + :param scaling_plan: Object containing scaling plan definitions. Required. + :type scaling_plan: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScalingPlan, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ScalingPlan - :raises: ~azure.core.exceptions.HttpResponseError + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlan: + """Create or update a scaling plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan: Object containing scaling plan definitions. Required. + :type scaling_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: Union[_models.ScalingPlan, IO], + **kwargs: Any + ) -> _models.ScalingPlan: + """Create or update a scaling plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan: Object containing scaling plan definitions. Is either a model type or a IO + type. Required. + :type scaling_plan: ~azure.mgmt.desktopvirtualization.models.ScalingPlan or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlan"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'scalingPlanName': self._serialize.url("scaling_plan_name", scaling_plan_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(scaling_plan, 'ScalingPlan') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlan] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scaling_plan, (IO, bytes)): + _content = scaling_plan + else: + _json = self._serialize.body(scaling_plan, "ScalingPlan") + + request = build_create_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -164,62 +521,66 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScalingPlan', pipeline_response) + deserialized = self._deserialize("ScalingPlan", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScalingPlan', pipeline_response) + deserialized = self._deserialize("ScalingPlan", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - scaling_plan_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, scaling_plan_name: str, **kwargs: Any + ) -> None: """Remove a scaling plan. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scaling_plan_name: The name of the scaling plan. + :param scaling_plan_name: The name of the scaling plan. Required. :type scaling_plan_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'scalingPlanName': self._serialize.url("scaling_plan_name", scaling_plan_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -229,127 +590,230 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}"} # type: ignore + @overload def update( self, - resource_group_name, # type: str - scaling_plan_name, # type: str - scaling_plan=None, # type: Optional["_models.ScalingPlanPatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ScalingPlan" + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: Optional[_models.ScalingPlanPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlan: """Update a scaling plan. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scaling_plan_name: The name of the scaling plan. + :param scaling_plan_name: The name of the scaling plan. Required. :type scaling_plan_name: str - :param scaling_plan: Object containing scaling plan definitions. - :type scaling_plan: ~desktop_virtualization_api_client.models.ScalingPlanPatch + :param scaling_plan: Object containing scaling plan definitions. Default value is None. + :type scaling_plan: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScalingPlan, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.ScalingPlan - :raises: ~azure.core.exceptions.HttpResponseError + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlan"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'scalingPlanName': self._serialize.url("scaling_plan_name", scaling_plan_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScalingPlan: + """Update a scaling plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan: Object containing scaling plan definitions. Default value is None. + :type scaling_plan: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ - # 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') + @distributed_trace + def update( + self, + resource_group_name: str, + scaling_plan_name: str, + scaling_plan: Optional[Union[_models.ScalingPlanPatch, IO]] = None, + **kwargs: Any + ) -> _models.ScalingPlan: + """Update a scaling plan. - body_content_kwargs = {} # type: Dict[str, Any] - if scaling_plan is not None: - body_content = self._serialize.body(scaling_plan, 'ScalingPlanPatch') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scaling_plan_name: The name of the scaling plan. Required. + :type scaling_plan_name: str + :param scaling_plan: Object containing scaling plan definitions. Is either a model type or a IO + type. Default value is None. + :type scaling_plan: ~azure.mgmt.desktopvirtualization.models.ScalingPlanPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScalingPlan or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.ScalingPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlan] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scaling_plan, (IO, bytes)): + _content = scaling_plan else: - body_content = None - 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) + if scaling_plan is not None: + _json = self._serialize.body(scaling_plan, "ScalingPlanPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + scaling_plan_name=scaling_plan_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScalingPlan', pipeline_response) + deserialized = self._deserialize("ScalingPlan", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans/{scalingPlanName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScalingPlanList"] + resource_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ScalingPlan"]: """List scaling plans. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScalingPlanList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.ScalingPlanList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScalingPlan or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ScalingPlan] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlanList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ScalingPlanList', pipeline_response) + deserialized = self._deserialize("ScalingPlanList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,7 +822,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -367,56 +833,83 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/scalingPlans"} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScalingPlanList"] + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ScalingPlan"]: """List scaling plans in subscription. + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScalingPlanList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.ScalingPlanList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScalingPlan or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ScalingPlan] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlanList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ScalingPlanList', pipeline_response) + deserialized = self._deserialize("ScalingPlanList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -425,7 +918,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -434,64 +929,92 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/scalingPlans'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/scalingPlans"} # type: ignore + + @distributed_trace def list_by_host_pool( self, - resource_group_name, # type: str - host_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScalingPlanList"] + resource_group_name: str, + host_pool_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ScalingPlan"]: """List scaling plan associated with hostpool. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScalingPlanList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.ScalingPlanList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScalingPlan or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.ScalingPlan] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScalingPlanList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScalingPlanList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_host_pool_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_host_pool.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ScalingPlanList', pipeline_response) + deserialized = self._deserialize("ScalingPlanList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -500,7 +1023,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -509,7 +1034,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/scalingPlans'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_host_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/scalingPlans"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_session_hosts_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_session_hosts_operations.py index 2480b7d82744..4629d73a2517 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_session_hosts_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_session_hosts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,163 +6,355 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, host_pool_name: str, session_host_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "sessionHostName": _SERIALIZER.url("session_host_name", session_host_name, "str", max_length=48, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + subscription_id: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "sessionHostName": _SERIALIZER.url("session_host_name", session_host_name, "str", max_length=48, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + subscription_id: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "sessionHostName": _SERIALIZER.url("session_host_name", session_host_name, "str", max_length=48, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + host_pool_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SessionHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SessionHostsOperations(object): - """SessionHostsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`session_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( - self, - resource_group_name, # type: str - host_pool_name, # type: str - session_host_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SessionHost" + self, resource_group_name: str, host_pool_name: str, session_host_name: str, **kwargs: Any + ) -> _models.SessionHost: """Get a session host. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SessionHost, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.SessionHost - :raises: ~azure.core.exceptions.HttpResponseError + :return: SessionHost or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.SessionHost + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SessionHost"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SessionHost] + + request = build_get_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('SessionHost', pipeline_response) + deserialized = self._deserialize("SessionHost", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}'} # type: ignore - def delete( + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - host_pool_name, # type: str - session_host_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: """Remove a SessionHost. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str - :param force: Force flag to force sessionHost deletion even when userSession exists. + :param force: Force flag to force sessionHost deletion even when userSession exists. Default + value is None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -171,140 +364,260 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + force: Optional[bool] = None, + session_host: Optional[_models.SessionHostPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SessionHost: + """Update a session host. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param session_host_name: The name of the session host within the specified host pool. + Required. + :type session_host_name: str + :param force: Force flag to update assign, unassign or reassign personal desktop. Default value + is None. + :type force: bool + :param session_host: Object containing SessionHost definitions. Default value is None. + :type session_host: ~azure.mgmt.desktopvirtualization.models.SessionHostPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SessionHost or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.SessionHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + force: Optional[bool] = None, + session_host: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SessionHost: + """Update a session host. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param session_host_name: The name of the session host within the specified host pool. + Required. + :type session_host_name: str + :param force: Force flag to update assign, unassign or reassign personal desktop. Default value + is None. + :type force: bool + :param session_host: Object containing SessionHost definitions. Default value is None. + :type session_host: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SessionHost or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.SessionHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace def update( self, - resource_group_name, # type: str - host_pool_name, # type: str - session_host_name, # type: str - force=None, # type: Optional[bool] - session_host=None, # type: Optional["_models.SessionHostPatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SessionHost" + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + force: Optional[bool] = None, + session_host: Optional[Union[_models.SessionHostPatch, IO]] = None, + **kwargs: Any + ) -> _models.SessionHost: """Update a session host. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str - :param force: Force flag to update assign, unassign or reassign personal desktop. + :param force: Force flag to update assign, unassign or reassign personal desktop. Default value + is None. :type force: bool - :param session_host: Object containing SessionHost definitions. - :type session_host: ~desktop_virtualization_api_client.models.SessionHostPatch + :param session_host: Object containing SessionHost definitions. Is either a model type or a IO + type. Default value is None. + :type session_host: ~azure.mgmt.desktopvirtualization.models.SessionHostPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SessionHost, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.SessionHost - :raises: ~azure.core.exceptions.HttpResponseError + :return: SessionHost or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.SessionHost + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SessionHost"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - - # 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] - if session_host is not None: - body_content = self._serialize.body(session_host, 'SessionHostPatch') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SessionHost] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(session_host, (IO, bytes)): + _content = session_host else: - body_content = None - 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) + if session_host is not None: + _json = self._serialize.body(session_host, "SessionHostPatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SessionHost', pipeline_response) + deserialized = self._deserialize("SessionHost", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - host_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SessionHostList"] + resource_group_name: str, + host_pool_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SessionHost"]: """List sessionHosts. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SessionHostList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.SessionHostList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SessionHost or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.SessionHost] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SessionHostList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SessionHostList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SessionHostList', pipeline_response) + deserialized = self._deserialize("SessionHostList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -313,7 +626,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -322,7 +637,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_start_menu_items_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_start_menu_items_operations.py index 6252ac496e01..d362d58ee7c6 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_start_menu_items_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_start_menu_items_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,190 @@ # 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 +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + application_group_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/startMenuItems", + ) # pylint: disable=line-too-long + 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 + ), + "applicationGroupName": _SERIALIZER.url( + "application_group_name", application_group_name, "str", max_length=64, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class StartMenuItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StartMenuItemsOperations(object): - """StartMenuItemsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`start_menu_items` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, - resource_group_name, # type: str - application_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StartMenuItemList"] + resource_group_name: str, + application_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.StartMenuItem"]: """List start menu items in the given application group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param application_group_name: The name of the application group. + :param application_group_name: The name of the application group. Required. :type application_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StartMenuItemList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.StartMenuItemList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StartMenuItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.StartMenuItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StartMenuItemList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StartMenuItemList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'applicationGroupName': self._serialize.url("application_group_name", application_group_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + application_group_name=application_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StartMenuItemList', pipeline_response) + deserialized = self._deserialize("StartMenuItemList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +198,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +209,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/startMenuItems'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/applicationGroups/{applicationGroupName}/startMenuItems"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_user_sessions_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_user_sessions_operations.py index 8d2bd84f3da7..78395f57e718 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_user_sessions_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_user_sessions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,411 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_host_pool_request( + resource_group_name: str, + host_pool_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/userSessions", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "sessionHostName": _SERIALIZER.url("session_host_name", session_host_name, "str", max_length=48, min_length=3), + "userSessionId": _SERIALIZER.url("user_session_id", user_session_id, "str", max_length=24, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + subscription_id: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "sessionHostName": _SERIALIZER.url("session_host_name", session_host_name, "str", max_length=48, min_length=3), + "userSessionId": _SERIALIZER.url("user_session_id", user_session_id, "str", max_length=24, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "sessionHostName": _SERIALIZER.url("session_host_name", session_host_name, "str", max_length=48, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_disconnect_request( + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/disconnect", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "sessionHostName": _SERIALIZER.url("session_host_name", session_host_name, "str", max_length=48, min_length=3), + "userSessionId": _SERIALIZER.url("user_session_id", user_session_id, "str", max_length=24, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_send_message_request( + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/sendMessage", + ) # pylint: disable=line-too-long + 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 + ), + "hostPoolName": _SERIALIZER.url("host_pool_name", host_pool_name, "str", max_length=64, min_length=3), + "sessionHostName": _SERIALIZER.url("session_host_name", session_host_name, "str", max_length=48, min_length=3), + "userSessionId": _SERIALIZER.url("user_session_id", user_session_id, "str", max_length=24, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class UserSessionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class UserSessionsOperations(object): - """UserSessionsOperations 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: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`user_sessions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_host_pool( self, - resource_group_name, # type: str - host_pool_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserSessionList"] + resource_group_name: str, + host_pool_name: str, + filter: Optional[str] = None, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.UserSession"]: """List userSessions. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param filter: OData filter expression. Valid properties for filtering are userprincipalname - and sessionstate. + and sessionstate. Default value is None. :type filter: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserSessionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.UserSessionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either UserSession or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.UserSession] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSessionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSessionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_host_pool.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_host_pool_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + subscription_id=self._config.subscription_id, + filter=filter, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_host_pool.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserSessionList', pipeline_response) + deserialized = self._deserialize("UserSessionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,7 +419,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,136 +430,146 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_host_pool.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/userSessions'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_host_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/userSessions"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - host_pool_name, # type: str - session_host_name, # type: str - user_session_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSession" + self, resource_group_name: str, host_pool_name: str, session_host_name: str, user_session_id: str, **kwargs: Any + ) -> _models.UserSession: """Get a userSession. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :param user_session_id: The name of the user session within the specified session host. + Required. :type user_session_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UserSession, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.UserSession - :raises: ~azure.core.exceptions.HttpResponseError + :return: UserSession or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.UserSession + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSession"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - 'userSessionId': self._serialize.url("user_session_id", user_session_id, 'str', max_length=24, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSession] + + request = build_get_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + user_session_id=user_session_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('UserSession', pipeline_response) + deserialized = self._deserialize("UserSession", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}'} # type: ignore - def delete( + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - host_pool_name, # type: str - session_host_name, # type: str - user_session_id, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: """Remove a userSession. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :param user_session_id: The name of the user session within the specified session host. + Required. :type user_session_id: str - :param force: Force flag to login off userSession. + :param force: Force flag to login off userSession. Default value is None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - 'userSessionId': self._serialize.url("user_session_id", user_session_id, 'str', max_length=24, min_length=1), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + user_session_id=user_session_id, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -260,65 +579,95 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}"} # type: ignore + @distributed_trace def list( self, - resource_group_name, # type: str - host_pool_name, # type: str - session_host_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserSessionList"] + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.UserSession"]: """List userSessions. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserSessionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.UserSessionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either UserSession or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.UserSession] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserSessionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UserSessionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserSessionList', pipeline_response) + deserialized = self._deserialize("UserSessionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -327,7 +676,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,64 +687,66 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions'} # type: ignore + return ItemPaged(get_next, extract_data) - def disconnect( - self, - resource_group_name, # type: str - host_pool_name, # type: str - session_host_name, # type: str - user_session_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions"} # type: ignore + + @distributed_trace + def disconnect( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, host_pool_name: str, session_host_name: str, user_session_id: str, **kwargs: Any + ) -> None: """Disconnect a userSession. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :param user_session_id: The name of the user session within the specified session host. + Required. :type user_session_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" - - # Construct URL - url = self.disconnect.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - 'userSessionId': self._serialize.url("user_session_id", user_session_id, 'str', max_length=24, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_disconnect_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + user_session_id=user_session_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.disconnect.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -403,72 +756,165 @@ def disconnect( if cls: return cls(pipeline_response, None, {}) - disconnect.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/disconnect'} # type: ignore + disconnect.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/disconnect"} # type: ignore - def send_message( + @overload + def send_message( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - host_pool_name, # type: str - session_host_name, # type: str - user_session_id, # type: str - send_message=None, # type: Optional["_models.SendMessage"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + send_message: Optional[_models.SendMessage] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: """Send a message to a user. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_pool_name: The name of the host pool within the specified resource group. + :param host_pool_name: The name of the host pool within the specified resource group. Required. :type host_pool_name: str :param session_host_name: The name of the session host within the specified host pool. + Required. :type session_host_name: str :param user_session_id: The name of the user session within the specified session host. + Required. :type user_session_id: str - :param send_message: Object containing message includes title and message body. - :type send_message: ~desktop_virtualization_api_client.models.SendMessage + :param send_message: Object containing message includes title and message body. Default value + is None. + :type send_message: ~azure.mgmt.desktopvirtualization.models.SendMessage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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 = "2021-09-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.send_message.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'hostPoolName': self._serialize.url("host_pool_name", host_pool_name, 'str', max_length=64, min_length=3), - 'sessionHostName': self._serialize.url("session_host_name", session_host_name, 'str', max_length=48, min_length=3), - 'userSessionId': self._serialize.url("user_session_id", user_session_id, 'str', max_length=24, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + def send_message( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + send_message: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Send a message to a user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param session_host_name: The name of the session host within the specified host pool. + Required. + :type session_host_name: str + :param user_session_id: The name of the user session within the specified session host. + Required. + :type user_session_id: str + :param send_message: Object containing message includes title and message body. Default value + is None. + :type send_message: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ - # 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') + @distributed_trace + def send_message( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + host_pool_name: str, + session_host_name: str, + user_session_id: str, + send_message: Optional[Union[_models.SendMessage, IO]] = None, + **kwargs: Any + ) -> None: + """Send a message to a user. - body_content_kwargs = {} # type: Dict[str, Any] - if send_message is not None: - body_content = self._serialize.body(send_message, 'SendMessage') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_pool_name: The name of the host pool within the specified resource group. Required. + :type host_pool_name: str + :param session_host_name: The name of the session host within the specified host pool. + Required. + :type session_host_name: str + :param user_session_id: The name of the user session within the specified session host. + Required. + :type user_session_id: str + :param send_message: Object containing message includes title and message body. Is either a + model type or a IO type. Default value is None. + :type send_message: ~azure.mgmt.desktopvirtualization.models.SendMessage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(send_message, (IO, bytes)): + _content = send_message else: - body_content = None - 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) + if send_message is not None: + _json = self._serialize.body(send_message, "SendMessage") + else: + _json = None + + request = build_send_message_request( + resource_group_name=resource_group_name, + host_pool_name=host_pool_name, + session_host_name=session_host_name, + user_session_id=user_session_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.send_message.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -478,4 +924,4 @@ def send_message( if cls: return cls(pipeline_response, None, {}) - send_message.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/sendMessage'} # type: ignore + send_message.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/hostPools/{hostPoolName}/sessionHosts/{sessionHostName}/userSessions/{userSessionId}/sendMessage"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_workspaces_operations.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_workspaces_operations.py index 909e892418f0..e168a27d9f3d 100644 --- a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_workspaces_operations.py +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/azure/mgmt/desktopvirtualization/operations/_workspaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,158 +6,451 @@ # 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 +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}", + ) # pylint: disable=line-too-long + 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 + ), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}", + ) # pylint: disable=line-too-long + 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 + ), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}", + ) # pylint: disable=line-too-long + 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 + ), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}", + ) # pylint: disable=line-too-long + 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 + ), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + if is_descending is not None: + _params["isDescending"] = _SERIALIZER.query("is_descending", is_descending, "bool") + if initial_skip is not None: + _params["initialSkip"] = _SERIALIZER.query("initial_skip", initial_skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-09")) # type: Literal["2022-09-09"] + accept = _headers.pop("Accept", "application/json") -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 WorkspacesOperations(object): - """WorkspacesOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/workspaces" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~desktop_virtualization_api_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.desktopvirtualization.DesktopVirtualizationMgmtClient`'s + :attr:`workspaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def get( - self, - resource_group_name, # type: str - workspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Workspace" + @distributed_trace + def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: """Get a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Workspace, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Workspace - :raises: ~azure.core.exceptions.HttpResponseError + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + + request = build_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}"} # type: ignore + + @overload def create_or_update( self, - resource_group_name, # type: str - workspace_name, # type: str - workspace, # type: "_models.Workspace" - **kwargs # type: Any - ): - # type: (...) -> "_models.Workspace" + resource_group_name: str, + workspace_name: str, + workspace: _models.Workspace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Create or update a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param workspace: Object containing Workspace definitions. Required. + :type workspace: ~azure.mgmt.desktopvirtualization.models.Workspace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + workspace: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Create or update a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param workspace: Object containing Workspace definitions. Required. + :type workspace: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, workspace_name: str, workspace: Union[_models.Workspace, IO], **kwargs: Any + ) -> _models.Workspace: """Create or update a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace: Object containing Workspace definitions. - :type workspace: ~desktop_virtualization_api_client.models.Workspace + :param workspace: Object containing Workspace definitions. Is either a model type or a IO type. + Required. + :type workspace: ~azure.mgmt.desktopvirtualization.models.Workspace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Workspace, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Workspace - :raises: ~azure.core.exceptions.HttpResponseError + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workspace, 'Workspace') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace, (IO, bytes)): + _content = workspace + else: + _json = self._serialize.body(workspace, "Workspace") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -164,62 +458,66 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - workspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> None: """Remove a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -229,127 +527,230 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}"} # type: ignore + @overload def update( self, - resource_group_name, # type: str - workspace_name, # type: str - workspace=None, # type: Optional["_models.WorkspacePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Workspace" + resource_group_name: str, + workspace_name: str, + workspace: Optional[_models.WorkspacePatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: """Update a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace: Object containing Workspace definitions. - :type workspace: ~desktop_virtualization_api_client.models.WorkspacePatch + :param workspace: Object containing Workspace definitions. Default value is None. + :type workspace: ~azure.mgmt.desktopvirtualization.models.WorkspacePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Workspace, or the result of cls(response) - :rtype: ~desktop_virtualization_api_client.models.Workspace - :raises: ~azure.core.exceptions.HttpResponseError + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @overload + def update( + self, + resource_group_name: str, + workspace_name: str, + workspace: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workspace: + """Update a workspace. - # 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') + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param workspace: Object containing Workspace definitions. Default value is None. + :type workspace: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ - body_content_kwargs = {} # type: Dict[str, Any] - if workspace is not None: - body_content = self._serialize.body(workspace, 'WorkspacePatch') + @distributed_trace + def update( + self, + resource_group_name: str, + workspace_name: str, + workspace: Optional[Union[_models.WorkspacePatch, IO]] = None, + **kwargs: Any + ) -> _models.Workspace: + """Update a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param workspace: Object containing Workspace definitions. Is either a model type or a IO type. + Default value is None. + :type workspace: ~azure.mgmt.desktopvirtualization.models.WorkspacePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Workspace or the result of cls(response) + :rtype: ~azure.mgmt.desktopvirtualization.models.Workspace + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace, (IO, bytes)): + _content = workspace else: - body_content = None - 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) + if workspace is not None: + _json = self._serialize.body(workspace, "WorkspacePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces/{workspaceName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkspaceList"] + resource_group_name: str, + page_size: Optional[int] = None, + is_descending: Optional[bool] = None, + initial_skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.Workspace"]: """List workspaces. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str + :param page_size: Number of items per page. Default value is None. + :type page_size: int + :param is_descending: Indicates whether the collection is descending. Default value is None. + :type is_descending: bool + :param initial_skip: Initial number of items to skip. Default value is None. + :type initial_skip: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.WorkspaceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Workspace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + page_size=page_size, + is_descending=is_descending, + initial_skip=initial_skip, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkspaceList', pipeline_response) + deserialized = self._deserialize("WorkspaceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,7 +759,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -367,56 +770,68 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces'} # type: ignore + return ItemPaged(get_next, extract_data) - def list_by_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkspaceList"] + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DesktopVirtualization/workspaces"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Workspace"]: """List workspaces in subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~desktop_virtualization_api_client.models.WorkspaceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Workspace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.desktopvirtualization.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-09-09"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-03-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkspaceList', pipeline_response) + deserialized = self._deserialize("WorkspaceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -425,7 +840,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -434,7 +851,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/workspaces'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DesktopVirtualization/workspaces"} # type: ignore diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_create.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_create.py new file mode 100644 index 000000000000..853d2d289127 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_create.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.applications.create_or_update( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + application_name="application1", + application={ + "properties": { + "commandLineArguments": "arguments", + "commandLineSetting": "Allow", + "description": "des1", + "filePath": "path", + "friendlyName": "friendly", + "iconIndex": 1, + "iconPath": "icon", + "showInPortal": True, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Application_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_delete.py new file mode 100644 index 000000000000..083b9025c334 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.applications.delete( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + application_name="application1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Application_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_get.py new file mode 100644 index 000000000000..02186140d825 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.applications.get( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + application_name="application1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Application_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_create.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_create.py new file mode 100644 index 000000000000..fd89027fddcf --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_create.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_group_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.application_groups.create_or_update( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + application_group={ + "location": "centralus", + "properties": { + "applicationGroupType": "RemoteApp", + "description": "des1", + "friendlyName": "friendly", + "hostPoolArmPath": "/subscriptions/daefabc0-95b4-48b3-b645-8a753a63c4fa/resourceGroups/resourceGroup1/providers/Microsoft.DesktopVirtualization/hostPools/hostPool1", + }, + "tags": {"tag1": "value1", "tag2": "value2"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ApplicationGroup_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_delete.py new file mode 100644 index 000000000000..74957cad4155 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_group_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.application_groups.delete( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ApplicationGroup_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_get.py new file mode 100644 index 000000000000..1b5787c4a5c1 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_group_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.application_groups.get( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ApplicationGroup_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_list.py new file mode 100644 index 000000000000..d6b4c3751b67 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_list.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_group_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.application_groups.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ApplicationGroup_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_list_by_resource_group.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_list_by_resource_group.py new file mode 100644 index 000000000000..6e05929c5e1d --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_group_list_by_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_group_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.application_groups.list_by_resource_group( + resource_group_name="resourceGroup1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ApplicationGroup_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_groups_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_groups_update.py new file mode 100644 index 000000000000..51a8ff7c19b8 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_groups_update.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_groups_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.application_groups.update( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ApplicationGroup_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_update.py new file mode 100644 index 000000000000..254be4c66873 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/application_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python application_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.applications.update( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + application_name="application1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Application_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/applications_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/applications_list.py new file mode 100644 index 000000000000..384a52fae901 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/applications_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python applications_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.applications.list( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Application_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_get.py new file mode 100644 index 000000000000..87e5f7ea84d7 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python desktop_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.desktops.get( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + desktop_name="SessionDesktop", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Desktop_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_list.py new file mode 100644 index 000000000000..b5aec2ddb040 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python desktop_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.desktops.list( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Desktop_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_update.py new file mode 100644 index 000000000000..60facbc7c8f7 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/desktop_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python desktop_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.desktops.update( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + desktop_name="SessionDesktop", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Desktop_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_create.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_create.py new file mode 100644 index 000000000000..a1ddd185ee61 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_create.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python host_pool_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.host_pools.create_or_update( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + host_pool={ + "location": "centralus", + "properties": { + "agentUpdate": { + "maintenanceWindowTimeZone": "Alaskan Standard Time", + "maintenanceWindows": [{"dayOfWeek": "Friday", "hour": 7}, {"dayOfWeek": "Saturday", "hour": 8}], + "type": "Scheduled", + "useSessionHostLocalTime": False, + }, + "customRdpProperty": None, + "description": "des1", + "friendlyName": "friendly", + "hostPoolType": "Pooled", + "loadBalancerType": "BreadthFirst", + "maxSessionLimit": 999999, + "personalDesktopAssignmentType": "Automatic", + "preferredAppGroupType": "Desktop", + "registrationInfo": { + "expirationTime": "2020-10-01T14:01:54.9571247Z", + "registrationTokenOperation": "Update", + }, + "ssoClientId": "client", + "ssoClientSecretKeyVaultPath": "https://keyvault/secret", + "ssoSecretType": "SharedKey", + "ssoadfsAuthority": "https://adfs", + "startVMOnConnect": False, + "vmTemplate": "{json:json}", + }, + "tags": {"tag1": "value1", "tag2": "value2"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/HostPool_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_delete.py new file mode 100644 index 000000000000..3c7413cb2dc3 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python host_pool_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.host_pools.delete( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/HostPool_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_get.py new file mode 100644 index 000000000000..f2225645c96e --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python host_pool_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.host_pools.get( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/HostPool_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_list.py new file mode 100644 index 000000000000..4b27010429b0 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_list.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python host_pool_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.host_pools.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/HostPool_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_list_by_resource_group.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_list_by_resource_group.py new file mode 100644 index 000000000000..e109e2623d96 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_list_by_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python host_pool_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.host_pools.list_by_resource_group( + resource_group_name="resourceGroup1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/HostPool_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_update.py new file mode 100644 index 000000000000..4fd354786661 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pool_update.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python host_pool_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.host_pools.update( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/HostPool_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pools_retrieve_registration_token_post.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pools_retrieve_registration_token_post.py new file mode 100644 index 000000000000..8a8440d14a8f --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/host_pools_retrieve_registration_token_post.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python host_pools_retrieve_registration_token_post.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.host_pools.retrieve_registration_token( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/HostPools_RetrieveRegistrationToken_Post.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_create.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_create.py new file mode 100644 index 000000000000..29841da93546 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_create.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python msix_package_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.msix_packages.create_or_update( + resource_group_name="resourceGroup1", + host_pool_name="hostpool1", + msix_package_full_name="msixpackagefullname", + msix_package={ + "properties": { + "displayName": "displayname", + "imagePath": "imagepath", + "isActive": False, + "isRegularRegistration": False, + "lastUpdated": "2008-09-22T14:01:54.9571247Z", + "packageApplications": [ + { + "appId": "ApplicationId", + "appUserModelID": "AppUserModelId", + "description": "application-desc", + "friendlyName": "friendlyname", + "iconImageName": "Apptile", + "rawIcon": "VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo", + "rawPng": "VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo", + } + ], + "packageDependencies": [ + { + "dependencyName": "MsixTest_Dependency_Name", + "minVersion": "version", + "publisher": "PublishedName", + } + ], + "packageFamilyName": "MsixPackage_FamilyName", + "packageName": "MsixPackage_name", + "packageRelativePath": "packagerelativepath", + "version": "version", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/MsixPackage_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_delete.py new file mode 100644 index 000000000000..5624b21593e3 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python msix_package_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.msix_packages.delete( + resource_group_name="resourceGroup1", + host_pool_name="hostpool1", + msix_package_full_name="packagefullname", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/MsixPackage_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_get.py new file mode 100644 index 000000000000..c6abd59be48a --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python msix_package_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.msix_packages.get( + resource_group_name="resourceGroup1", + host_pool_name="hostpool1", + msix_package_full_name="packagefullname", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/MsixPackage_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_list.py new file mode 100644 index 000000000000..a5c88648472a --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python msix_package_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.msix_packages.list( + resource_group_name="resourceGroup1", + host_pool_name="hostpool1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/MsixPackage_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_update.py new file mode 100644 index 000000000000..10205d88955e --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/msix_package_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python msix_package_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.msix_packages.update( + resource_group_name="resourceGroup1", + host_pool_name="hostpool1", + msix_package_full_name="msixpackagefullname", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/MsixPackage_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/operation_description_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/operation_description_list.py new file mode 100644 index 000000000000..47d4fc3236cb --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/operation_description_list.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python operation_description_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/OperationDescription_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_list_by_host_pool.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_list_by_host_pool.py new file mode 100644 index 000000000000..ea09c71f58c6 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_list_by_host_pool.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plan_list_by_host_pool.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plans.list_by_host_pool( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlan_ListByHostPool.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_create.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_create.py new file mode 100644 index 000000000000..bcee7812adab --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_create.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plan_pooled_schedules_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plan_pooled_schedules.create( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + scaling_plan_schedule_name="scalingPlanScheduleWeekdays1", + scaling_plan_schedule={ + "properties": { + "daysOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"], + "offPeakLoadBalancingAlgorithm": "DepthFirst", + "offPeakStartTime": {"hour": 20, "minute": 0}, + "peakLoadBalancingAlgorithm": "BreadthFirst", + "peakStartTime": {"hour": 8, "minute": 0}, + "rampDownCapacityThresholdPct": 50, + "rampDownForceLogoffUsers": True, + "rampDownLoadBalancingAlgorithm": "DepthFirst", + "rampDownMinimumHostsPct": 20, + "rampDownNotificationMessage": "message", + "rampDownStartTime": {"hour": 18, "minute": 0}, + "rampDownWaitTimeMinutes": 30, + "rampUpCapacityThresholdPct": 80, + "rampUpLoadBalancingAlgorithm": "DepthFirst", + "rampUpMinimumHostsPct": 20, + "rampUpStartTime": {"hour": 6, "minute": 0}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlanPooledSchedule_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_delete.py new file mode 100644 index 000000000000..41b82f74a3b1 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plan_pooled_schedules_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plan_pooled_schedules.delete( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + scaling_plan_schedule_name="scalingPlanScheduleWeekdays1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlanPooledSchedule_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_get.py new file mode 100644 index 000000000000..ffc0f4214dfc --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plan_pooled_schedules_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plan_pooled_schedules.get( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + scaling_plan_schedule_name="scalingPlanScheduleWeekdays1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlanPooledSchedule_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_list.py new file mode 100644 index 000000000000..7618ddfbf348 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plan_pooled_schedules_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plan_pooled_schedules.list( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlanPooledSchedule_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_update.py new file mode 100644 index 000000000000..5a22fce5927d --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plan_pooled_schedules_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plan_pooled_schedules_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plan_pooled_schedules.update( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + scaling_plan_schedule_name="scalingPlanScheduleWeekdays1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlanPooledSchedule_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_create.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_create.py new file mode 100644 index 000000000000..d0a8a0934330 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_create.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plans_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plans.create( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + scaling_plan={ + "location": "centralus", + "properties": { + "description": "Description of Scaling Plan", + "exclusionTag": "value", + "friendlyName": "Scaling Plan 1", + "hostPoolReferences": [ + { + "hostPoolArmPath": "/subscriptions/daefabc0-95b4-48b3-b645-8a753a63c4fa/resourceGroups/resourceGroup1/providers/Microsoft.DesktopVirtualization/hostPools/hostPool1", + "scalingPlanEnabled": True, + } + ], + "hostPoolType": "Pooled", + "schedules": [ + { + "daysOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"], + "name": "schedule1", + "offPeakLoadBalancingAlgorithm": "DepthFirst", + "offPeakStartTime": {"hour": 20, "minute": 0}, + "peakLoadBalancingAlgorithm": "BreadthFirst", + "peakStartTime": {"hour": 8, "minute": 0}, + "rampDownCapacityThresholdPct": 50, + "rampDownForceLogoffUsers": True, + "rampDownLoadBalancingAlgorithm": "DepthFirst", + "rampDownMinimumHostsPct": 20, + "rampDownNotificationMessage": "message", + "rampDownStartTime": {"hour": 18, "minute": 0}, + "rampDownWaitTimeMinutes": 30, + "rampUpCapacityThresholdPct": 80, + "rampUpLoadBalancingAlgorithm": "DepthFirst", + "rampUpMinimumHostsPct": 20, + "rampUpStartTime": {"hour": 6, "minute": 0}, + } + ], + "timeZone": "Central Standard Time", + }, + "tags": {"tag1": "value1", "tag2": "value2"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlan_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_delete.py new file mode 100644 index 000000000000..c87b87b04a41 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plans_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plans.delete( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlan_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_get.py new file mode 100644 index 000000000000..1140d0c3d8ca --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plans_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plans.get( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlan_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_list_by_resource_group.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_list_by_resource_group.py new file mode 100644 index 000000000000..c6520ea31cd5 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_list_by_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plans_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plans.list_by_resource_group( + resource_group_name="resourceGroup1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlan_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_list_by_subscription.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_list_by_subscription.py new file mode 100644 index 000000000000..865386a7217b --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plans_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plans.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlan_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_update.py new file mode 100644 index 000000000000..c1bea745be0b --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/scaling_plans_update.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python scaling_plans_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.scaling_plans.update( + resource_group_name="resourceGroup1", + scaling_plan_name="scalingPlan1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/ScalingPlan_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_delete.py new file mode 100644 index 000000000000..8895ee83f760 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python session_host_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.session_hosts.delete( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + session_host_name="sessionHost1.microsoft.com", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/SessionHost_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_get.py new file mode 100644 index 000000000000..39d15ddc6283 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python session_host_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.session_hosts.get( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + session_host_name="sessionHost1.microsoft.com", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/SessionHost_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_list.py new file mode 100644 index 000000000000..9261e830a9d7 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python session_host_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.session_hosts.list( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/SessionHost_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_update.py new file mode 100644 index 000000000000..f67812be3ba2 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/session_host_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python session_host_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.session_hosts.update( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + session_host_name="sessionHost1.microsoft.com", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/SessionHost_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/start_menu_item_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/start_menu_item_list.py new file mode 100644 index 000000000000..61ccb0591341 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/start_menu_item_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python start_menu_item_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.start_menu_items.list( + resource_group_name="resourceGroup1", + application_group_name="applicationGroup1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/StartMenuItem_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_delete.py new file mode 100644 index 000000000000..c40510191a2d --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_delete.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python user_session_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.user_sessions.delete( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + session_host_name="sessionHost1.microsoft.com", + user_session_id="1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/UserSession_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_disconnect_post.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_disconnect_post.py new file mode 100644 index 000000000000..8966283bc266 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_disconnect_post.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python user_session_disconnect_post.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.user_sessions.disconnect( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + session_host_name="sessionHost1.microsoft.com", + user_session_id="1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/UserSession_Disconnect_Post.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_get.py new file mode 100644 index 000000000000..a3c5b74b65c7 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python user_session_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.user_sessions.get( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + session_host_name="sessionHost1.microsoft.com", + user_session_id="1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/UserSession_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_list.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_list.py new file mode 100644 index 000000000000..0bd2ac67184d --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python user_session_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.user_sessions.list( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + session_host_name="sessionHost1.microsoft.com", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/UserSession_List.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_list_by_host_pool.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_list_by_host_pool.py new file mode 100644 index 000000000000..62b1c50c96f0 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_list_by_host_pool.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python user_session_list_by_host_pool.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.user_sessions.list_by_host_pool( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/UserSession_ListByHostPool.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_send_message_post.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_send_message_post.py new file mode 100644 index 000000000000..a3a6c2611412 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/user_session_send_message_post.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python user_session_send_message_post.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.user_sessions.send_message( + resource_group_name="resourceGroup1", + host_pool_name="hostPool1", + session_host_name="sessionHost1.microsoft.com", + user_session_id="1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/UserSession_SendMessage_Post.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_create.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_create.py new file mode 100644 index 000000000000..16e438c889e7 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_create.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python workspace_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.workspaces.create_or_update( + resource_group_name="resourceGroup1", + workspace_name="workspace1", + workspace={ + "location": "centralus", + "properties": {"description": "des1", "friendlyName": "friendly"}, + "tags": {"tag1": "value1", "tag2": "value2"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Workspace_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_delete.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_delete.py new file mode 100644 index 000000000000..adeec20cef44 --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python workspace_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.workspaces.delete( + resource_group_name="resourceGroup1", + workspace_name="workspace1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Workspace_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_get.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_get.py new file mode 100644 index 000000000000..667f31d0a8aa --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python workspace_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.workspaces.get( + resource_group_name="resourceGroup1", + workspace_name="workspace1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Workspace_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_list_by_resource_group.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_list_by_resource_group.py new file mode 100644 index 000000000000..49dde33f168e --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_list_by_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python workspace_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.workspaces.list_by_resource_group( + resource_group_name="resourceGroup1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Workspace_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_list_by_subscription.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_list_by_subscription.py new file mode 100644 index 000000000000..7806efd32f9c --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python workspace_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.workspaces.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Workspace_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_update.py b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_update.py new file mode 100644 index 000000000000..a00dc1298f3e --- /dev/null +++ b/sdk/desktopvirtualization/azure-mgmt-desktopvirtualization/generated_samples/workspace_update.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.desktopvirtualization import DesktopVirtualizationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-desktopvirtualization +# USAGE + python workspace_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DesktopVirtualizationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="daefabc0-95b4-48b3-b645-8a753a63c4fa", + ) + + response = client.workspaces.update( + resource_group_name="resourceGroup1", + workspace_name="workspace1", + ) + print(response) + + +# x-ms-original-file: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2022-09-09/examples/Workspace_Update.json +if __name__ == "__main__": + main()