From c66f4743fa2a753b99ff6c2fc3f00381765b0141 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 28 Jul 2023 09:00:19 +0000 Subject: [PATCH] CodeGen from PR 25030 in Azure/azure-rest-api-specs Merge 59873242b5ef6ea20c3db10dfab72e3040973de2 into 5e2f303761697659678ff120202027ff51bb0ea9 --- sdk/hdinsight/azure-mgmt-hdinsight/_meta.json | 8 +- .../azure/mgmt/hdinsight/_version.py | 2 +- .../azure-mgmt-hdinsightonaks/CHANGELOG.md | 5 + .../azure-mgmt-hdinsightonaks/LICENSE | 21 + .../azure-mgmt-hdinsightonaks/MANIFEST.in | 8 + .../azure-mgmt-hdinsightonaks/README.md | 64 + .../azure-mgmt-hdinsightonaks/_meta.json | 11 + .../azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/hdinsightonaks/__init__.py | 26 + .../mgmt/hdinsightonaks/_configuration.py | 66 + .../_hd_insight_on_aks_mgmt_client.py | 123 + .../azure/mgmt/hdinsightonaks/_patch.py | 20 + .../mgmt/hdinsightonaks/_serialization.py | 1996 ++++++++ .../azure/mgmt/hdinsightonaks/_vendor.py | 30 + .../azure/mgmt/hdinsightonaks/_version.py | 9 + .../azure/mgmt/hdinsightonaks/aio/__init__.py | 23 + .../mgmt/hdinsightonaks/aio/_configuration.py | 66 + .../aio/_hd_insight_on_aks_mgmt_client.py | 123 + .../azure/mgmt/hdinsightonaks/aio/_patch.py | 20 + .../hdinsightonaks/aio/operations/__init__.py | 31 + ...ilable_cluster_pool_versions_operations.py | 140 + .../_available_cluster_versions_operations.py | 140 + .../operations/_cluster_jobs_operations.py | 393 ++ .../operations/_cluster_pools_operations.py | 876 ++++ .../aio/operations/_clusters_operations.py | 1340 +++++ .../aio/operations/_locations_operations.py | 176 + .../aio/operations/_operations.py | 133 + .../hdinsightonaks/aio/operations/_patch.py | 20 + .../mgmt/hdinsightonaks/models/__init__.py | 231 + .../_hd_insight_on_aks_mgmt_client_enums.py | 120 + .../mgmt/hdinsightonaks/models/_models_py3.py | 4396 +++++++++++++++++ .../mgmt/hdinsightonaks/models/_patch.py | 20 + .../hdinsightonaks/operations/__init__.py | 31 + ...ilable_cluster_pool_versions_operations.py | 170 + .../_available_cluster_versions_operations.py | 170 + .../operations/_cluster_jobs_operations.py | 463 ++ .../operations/_cluster_pools_operations.py | 1059 ++++ .../operations/_clusters_operations.py | 1633 ++++++ .../operations/_locations_operations.py | 210 + .../hdinsightonaks/operations/_operations.py | 155 + .../mgmt/hdinsightonaks/operations/_patch.py | 20 + .../azure/mgmt/hdinsightonaks/py.typed | 1 + .../create_autoscale_cluster.py | 94 + .../generated_samples/create_cluster_pool.py | 48 + .../generated_samples/create_spark_cluster.py | 98 + .../generated_samples/delete_cluster.py | 41 + .../generated_samples/delete_cluster_pool.py | 40 + .../generated_samples/get_cluster.py | 42 + .../get_cluster_instance_view.py | 42 + .../generated_samples/get_cluster_pool.py | 41 + .../generated_samples/get_operations.py | 39 + .../list_available_cluster_pool_versions.py | 41 + .../list_available_cluster_versions.py | 41 + .../list_cluster_instance_views.py | 43 + .../generated_samples/list_cluster_jobs.py | 43 + .../generated_samples/list_cluster_pools.py | 41 + .../list_cluster_pools_subscription.py | 39 + .../list_cluster_service_configs.py | 43 + .../list_clusters_by_cluster_pool_name.py | 42 + .../locations_name_availability.py | 41 + .../generated_samples/patch_cluster.py | 113 + .../generated_samples/patch_cluster_pool.py | 42 + .../generated_samples/resize_cluster.py | 43 + .../generated_samples/run_cluster_job.py | 56 + .../sdk_packaging.toml | 11 + .../azure-mgmt-hdinsightonaks/setup.py | 83 + sdk/hdinsight/ci.yml | 2 + 68 files changed, 15755 insertions(+), 5 deletions(-) create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/CHANGELOG.md create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/LICENSE create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/MANIFEST.in create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/README.md create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/_meta.json create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/__init__.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/__init__.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/__init__.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_configuration.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_hd_insight_on_aks_mgmt_client.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_patch.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_serialization.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_vendor.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_version.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/__init__.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_configuration.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_hd_insight_on_aks_mgmt_client.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_patch.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/__init__.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_available_cluster_pool_versions_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_available_cluster_versions_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_cluster_jobs_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_cluster_pools_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_clusters_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_locations_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_patch.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/__init__.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_hd_insight_on_aks_mgmt_client_enums.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_models_py3.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_patch.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/__init__.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_available_cluster_pool_versions_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_available_cluster_versions_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_cluster_jobs_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_cluster_pools_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_clusters_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_locations_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_patch.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/py.typed create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_autoscale_cluster.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_cluster_pool.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_spark_cluster.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/delete_cluster.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/delete_cluster_pool.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster_instance_view.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster_pool.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_operations.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_available_cluster_pool_versions.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_available_cluster_versions.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_instance_views.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_jobs.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_pools.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_pools_subscription.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_service_configs.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_clusters_by_cluster_pool_name.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/locations_name_availability.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/patch_cluster.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/patch_cluster_pool.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/resize_cluster.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/run_cluster_job.py create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/sdk_packaging.toml create mode 100644 sdk/hdinsight/azure-mgmt-hdinsightonaks/setup.py diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/_meta.json b/sdk/hdinsight/azure-mgmt-hdinsight/_meta.json index b3161ca4c669..71d81f1ec2fd 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/_meta.json +++ b/sdk/hdinsight/azure-mgmt-hdinsight/_meta.json @@ -1,11 +1,11 @@ { - "commit": "237afa17929313c909f72f2fea59f4437e305c99", + "commit": "b67cb7d51e2981de51e93092f45803f6ec11cb46", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.6", "use": [ "@autorest/python@6.6.0", - "@autorest/modelerfour@4.24.3" + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/hdinsight/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/hdinsight/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.6.0 --use=@autorest/modelerfour@4.26.2 --version=3.9.6 --version-tolerant=False", "readme": "specification/hdinsight/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_version.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_version.py index e25f4fc7373b..e5754a47ce68 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_version.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "9.0.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/CHANGELOG.md b/sdk/hdinsight/azure-mgmt-hdinsightonaks/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/LICENSE b/sdk/hdinsight/azure-mgmt-hdinsightonaks/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/MANIFEST.in b/sdk/hdinsight/azure-mgmt-hdinsightonaks/MANIFEST.in new file mode 100644 index 000000000000..6c3dc9f044bc --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/MANIFEST.in @@ -0,0 +1,8 @@ +include _meta.json +recursive-include tests *.py *.json +recursive-include samples *.py *.md +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/hdinsightonaks/py.typed diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/README.md b/sdk/hdinsight/azure-mgmt-hdinsightonaks/README.md new file mode 100644 index 000000000000..4b4d8d9f3dac --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/README.md @@ -0,0 +1,64 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.7+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +## Getting started + +### Prerequisites + +- Python 3.7+ is required to use this package. +- [Azure subscription](https://azure.microsoft.com/free/) + +### Install the package + +```bash +pip install azure-mgmt-hdinsightonaks +pip install azure-identity +``` + +### Authentication + +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` for Azure client secret. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, client can be authenticated by following code: + +```python +from azure.identity import DefaultAzureCredential +from azure.mgmt.hdinsightonaks import +import os + +sub_id = os.getenv("AZURE_SUBSCRIPTION_ID") +client = (credential=DefaultAzureCredential(), subscription_id=sub_id) +``` + +## Examples + +Code samples for this package can be found at: +- [Search MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +## Troubleshooting + +## Next steps + +## Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-hdinsightonaks%2FREADME.png) diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/_meta.json b/sdk/hdinsight/azure-mgmt-hdinsightonaks/_meta.json new file mode 100644 index 000000000000..7882d2c2952c --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "b67cb7d51e2981de51e93092f45803f6ec11cb46", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.6", + "use": [ + "@autorest/python@6.6.0", + "@autorest/modelerfour@4.26.2" + ], + "autorest_command": "autorest specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/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.6.0 --use=@autorest/modelerfour@4.26.2 --version=3.9.6 --version-tolerant=False", + "readme": "specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/readme.md" +} \ No newline at end of file diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/__init__.py new file mode 100644 index 000000000000..ce8332ff7738 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/__init__.py @@ -0,0 +1,26 @@ +# 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 ._hd_insight_on_aks_mgmt_client import HDInsightOnAksMgmtClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HDInsightOnAksMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_configuration.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_configuration.py new file mode 100644 index 000000000000..edac88d535de --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class HDInsightOnAksMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for HDInsightOnAksMgmtClient. + + 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. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(HDInsightOnAksMgmtClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-06-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-hdinsightonaks/{}".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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_hd_insight_on_aks_mgmt_client.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_hd_insight_on_aks_mgmt_client.py new file mode 100644 index 000000000000..0bf0bb2405ab --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_hd_insight_on_aks_mgmt_client.py @@ -0,0 +1,123 @@ +# 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 as _models +from ._configuration import HDInsightOnAksMgmtClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + AvailableClusterPoolVersionsOperations, + AvailableClusterVersionsOperations, + ClusterJobsOperations, + ClusterPoolsOperations, + ClustersOperations, + LocationsOperations, + Operations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class HDInsightOnAksMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """HDInsight On Aks Management Client. + + :ivar cluster_pools: ClusterPoolsOperations operations + :vartype cluster_pools: azure.mgmt.hdinsightonaks.operations.ClusterPoolsOperations + :ivar clusters: ClustersOperations operations + :vartype clusters: azure.mgmt.hdinsightonaks.operations.ClustersOperations + :ivar cluster_jobs: ClusterJobsOperations operations + :vartype cluster_jobs: azure.mgmt.hdinsightonaks.operations.ClusterJobsOperations + :ivar locations: LocationsOperations operations + :vartype locations: azure.mgmt.hdinsightonaks.operations.LocationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.hdinsightonaks.operations.Operations + :ivar available_cluster_pool_versions: AvailableClusterPoolVersionsOperations operations + :vartype available_cluster_pool_versions: + azure.mgmt.hdinsightonaks.operations.AvailableClusterPoolVersionsOperations + :ivar available_cluster_versions: AvailableClusterVersionsOperations operations + :vartype available_cluster_versions: + azure.mgmt.hdinsightonaks.operations.AvailableClusterVersionsOperations + :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. The value must be an UUID. 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 "2023-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = HDInsightOnAksMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client: ARMPipelineClient = 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.cluster_pools = ClusterPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.cluster_jobs = ClusterJobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_cluster_pool_versions = AvailableClusterPoolVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.available_cluster_versions = AvailableClusterVersionsOperations( + 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) -> None: + self._client.close() + + def __enter__(self) -> "HDInsightOnAksMgmtClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_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/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_serialization.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_serialization.py new file mode 100644 index 000000000000..842ae727fbbc --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_serialization.py @@ -0,0 +1,1996 @@ +# -------------------------------------------------------------------------- +# +# 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 +# pyright: reportUnnecessaryTypeIgnoreComment=false + +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 +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + + +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: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> 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: Optional[Union[AnyStr, IO]], headers: 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 + unicode_str = str + +_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 # type: ignore +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 +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Dict[str, Any] = {} + for k in kwargs: + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node.""" + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to azure from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + Remove the polymorphic key from the initial data. + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + """ + return key.replace("\\.", ".") + + +class Serializer(object): + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > 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: Optional[Mapping[str, Type[ModelType]]] = 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[str, Type[ModelType]] = 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) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + 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) # type: ignore + 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) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _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_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, 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 = [ # type: ignore + 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 is AzureCoreNull: + return None + 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): # type: ignore + # 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) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + 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: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _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: Optional[Mapping[str, Type[ModelType]]] = 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[str, Type[ModelType]] = 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 # type: ignore + 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 # type: ignore + 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 deserialize. + """ + 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__ # type: ignore + + 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 deserialize. + :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) # type: ignore + 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) # type: ignore + 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): # type: ignore + 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)) # type: ignore + + @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) # type: ignore + attr = attr + padding # type: ignore + 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) # type: ignore + 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) # type: ignore + + @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): # type: ignore + 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): # type: ignore + 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) # type: ignore + 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() # type: ignore + 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) # type: ignore + 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/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_vendor.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_vendor.py new file mode 100644 index 000000000000..bd0df84f5319 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_vendor.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------- +# 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 List, cast + +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: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_version.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/__init__.py new file mode 100644 index 000000000000..ed9a8aa0178c --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/__init__.py @@ -0,0 +1,23 @@ +# 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 ._hd_insight_on_aks_mgmt_client import HDInsightOnAksMgmtClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HDInsightOnAksMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_configuration.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_configuration.py new file mode 100644 index 000000000000..7bcf22f367c9 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class HDInsightOnAksMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for HDInsightOnAksMgmtClient. + + 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. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(HDInsightOnAksMgmtClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-06-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-hdinsightonaks/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_hd_insight_on_aks_mgmt_client.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_hd_insight_on_aks_mgmt_client.py new file mode 100644 index 000000000000..77ddd02cc550 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_hd_insight_on_aks_mgmt_client.py @@ -0,0 +1,123 @@ +# 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 as _models +from .._serialization import Deserializer, Serializer +from ._configuration import HDInsightOnAksMgmtClientConfiguration +from .operations import ( + AvailableClusterPoolVersionsOperations, + AvailableClusterVersionsOperations, + ClusterJobsOperations, + ClusterPoolsOperations, + ClustersOperations, + LocationsOperations, + Operations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class HDInsightOnAksMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """HDInsight On Aks Management Client. + + :ivar cluster_pools: ClusterPoolsOperations operations + :vartype cluster_pools: azure.mgmt.hdinsightonaks.aio.operations.ClusterPoolsOperations + :ivar clusters: ClustersOperations operations + :vartype clusters: azure.mgmt.hdinsightonaks.aio.operations.ClustersOperations + :ivar cluster_jobs: ClusterJobsOperations operations + :vartype cluster_jobs: azure.mgmt.hdinsightonaks.aio.operations.ClusterJobsOperations + :ivar locations: LocationsOperations operations + :vartype locations: azure.mgmt.hdinsightonaks.aio.operations.LocationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.hdinsightonaks.aio.operations.Operations + :ivar available_cluster_pool_versions: AvailableClusterPoolVersionsOperations operations + :vartype available_cluster_pool_versions: + azure.mgmt.hdinsightonaks.aio.operations.AvailableClusterPoolVersionsOperations + :ivar available_cluster_versions: AvailableClusterVersionsOperations operations + :vartype available_cluster_versions: + azure.mgmt.hdinsightonaks.aio.operations.AvailableClusterVersionsOperations + :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. The value must be an UUID. 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 "2023-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = HDInsightOnAksMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client: AsyncARMPipelineClient = 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.cluster_pools = ClusterPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.cluster_jobs = ClusterJobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_cluster_pool_versions = AvailableClusterPoolVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.available_cluster_versions = AvailableClusterVersionsOperations( + 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) -> "HDInsightOnAksMgmtClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/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/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/__init__.py new file mode 100644 index 000000000000..3c44ccd0cd62 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# 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 ._cluster_pools_operations import ClusterPoolsOperations +from ._clusters_operations import ClustersOperations +from ._cluster_jobs_operations import ClusterJobsOperations +from ._locations_operations import LocationsOperations +from ._operations import Operations +from ._available_cluster_pool_versions_operations import AvailableClusterPoolVersionsOperations +from ._available_cluster_versions_operations import AvailableClusterVersionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ClusterPoolsOperations", + "ClustersOperations", + "ClusterJobsOperations", + "LocationsOperations", + "Operations", + "AvailableClusterPoolVersionsOperations", + "AvailableClusterVersionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_available_cluster_pool_versions_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_available_cluster_pool_versions_operations.py new file mode 100644 index 000000000000..154b64ece7f4 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_available_cluster_pool_versions_operations.py @@ -0,0 +1,140 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._available_cluster_pool_versions_operations import build_list_by_location_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AvailableClusterPoolVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.aio.HDInsightOnAksMgmtClient`'s + :attr:`available_cluster_pool_versions` 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 + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.ClusterPoolVersion"]: + """Returns a list of available cluster pool versions. + + :param location: The name of the Azure region. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterPoolVersion or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterPoolVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterPoolVersionsListResult] = kwargs.pop("cls", None) + + 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_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterPoolVersionsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_location.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/availableClusterPoolVersions" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_available_cluster_versions_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_available_cluster_versions_operations.py new file mode 100644 index 000000000000..f8f957645147 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_available_cluster_versions_operations.py @@ -0,0 +1,140 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._available_cluster_versions_operations import build_list_by_location_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AvailableClusterVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.aio.HDInsightOnAksMgmtClient`'s + :attr:`available_cluster_versions` 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 + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.ClusterVersion"]: + """Returns a list of available cluster versions. + + :param location: The name of the Azure region. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterVersion or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterVersionsListResult] = kwargs.pop("cls", None) + + 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_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterVersionsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_location.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/availableClusterVersions" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_cluster_jobs_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_cluster_jobs_operations.py new file mode 100644 index 000000000000..3375332877fb --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_cluster_jobs_operations.py @@ -0,0 +1,393 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._cluster_jobs_operations import build_list_request, build_run_job_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ClusterJobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.aio.HDInsightOnAksMgmtClient`'s + :attr:`cluster_jobs` 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") + + async def _run_job_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_job: Union[_models.ClusterJob, IO], + **kwargs: Any + ) -> Optional[_models.ClusterJob]: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ClusterJob]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_job, (IOBase, bytes)): + _content = cluster_job + else: + _json = self._serialize.body(cluster_job, "ClusterJob") + + request = build_run_job_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._run_job_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ClusterJob", pipeline_response) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _run_job_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/runJob" + } + + @overload + async def begin_run_job( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_job: _models.ClusterJob, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterJob]: + """Operations on jobs of HDInsight on AKS cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_job: The Cluster job. Required. + :type cluster_job: ~azure.mgmt.hdinsightonaks.models.ClusterJob + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterJob or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_run_job( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_job: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterJob]: + """Operations on jobs of HDInsight on AKS cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_job: The Cluster job. Required. + :type cluster_job: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterJob or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_run_job( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_job: Union[_models.ClusterJob, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterJob]: + """Operations on jobs of HDInsight on AKS cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_job: The Cluster job. Is either a ClusterJob type or a IO type. Required. + :type cluster_job: ~azure.mgmt.hdinsightonaks.models.ClusterJob 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterJob or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterJob] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._run_job_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + cluster_job=cluster_job, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterJob", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_run_job.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/runJob" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ClusterJob"]: + """Get jobs of HDInsight on AKS cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterJob or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterJobList] = kwargs.pop("cls", None) + + 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, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterJobList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/jobs" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_cluster_pools_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_cluster_pools_operations.py new file mode 100644 index 000000000000..a34e0498e5c5 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_cluster_pools_operations.py @@ -0,0 +1,876 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._cluster_pools_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_tags_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ClusterPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.aio.HDInsightOnAksMgmtClient`'s + :attr:`cluster_pools` 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, cluster_pool_name: str, **kwargs: Any) -> _models.ClusterPool: + """Gets a cluster pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClusterPool or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.ClusterPool + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool: Union[_models.ClusterPool, IO], + **kwargs: Any + ) -> _models.ClusterPool: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_pool, (IOBase, bytes)): + _content = cluster_pool + else: + _json = self._serialize.body(cluster_pool, "ClusterPool") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_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_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool: _models.ClusterPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPool]: + """Creates or updates a cluster pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool: The Cluster Pool to create. Required. + :type cluster_pool: ~azure.mgmt.hdinsightonaks.models.ClusterPool + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPool]: + """Creates or updates a cluster pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool: The Cluster Pool to create. Required. + :type cluster_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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool: Union[_models.ClusterPool, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPool]: + """Creates or updates a cluster pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool: The Cluster Pool to create. Is either a ClusterPool type or a IO type. + Required. + :type cluster_pool: ~azure.mgmt.hdinsightonaks.models.ClusterPool 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_pool=cluster_pool, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterPool", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + async def _update_tags_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool_tags: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ClusterPool: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_pool_tags, (IOBase, bytes)): + _content = cluster_pool_tags + else: + _json = self._serialize.body(cluster_pool_tags, "TagsObject") + + request = build_update_tags_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_tags_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_tags_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + @overload + async def begin_update_tags( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool_tags: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPool]: + """Updates an existing Cluster Pool Tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool_tags: Parameters supplied to update tags. Required. + :type cluster_pool_tags: ~azure.mgmt.hdinsightonaks.models.TagsObject + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_tags( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPool]: + """Updates an existing Cluster Pool Tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool_tags: Parameters supplied to update tags. Required. + :type cluster_pool_tags: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_tags( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool_tags: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPool]: + """Updates an existing Cluster Pool Tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool_tags: Parameters supplied to update tags. Is either a TagsObject type or a + IO type. Required. + :type cluster_pool_tags: ~azure.mgmt.hdinsightonaks.models.TagsObject 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_tags_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_pool_tags=cluster_pool_tags, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterPool", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_pool_name: str, **kwargs: Any + ) -> None: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cluster_pool_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a Cluster Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ClusterPool"]: + """Gets the list of Cluster Pools within a Subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterPool or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterPoolListResult] = kwargs.pop("cls", None) + + 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_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) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterPoolListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusterpools" + } + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ClusterPool"]: + """Lists the HDInsight cluster pools under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterPool or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterPoolListResult] = kwargs.pop("cls", None) + + 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterPoolListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_clusters_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_clusters_operations.py new file mode 100644 index 000000000000..51038adc9991 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_clusters_operations.py @@ -0,0 +1,1340 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._clusters_operations import ( + build_create_request, + build_delete_request, + build_get_instance_view_request, + build_get_request, + build_list_by_cluster_pool_name_request, + build_list_instance_views_request, + build_list_service_configs_request, + build_resize_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.aio.HDInsightOnAksMgmtClient`'s + :attr:`clusters` 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 + def list_by_cluster_pool_name( + self, resource_group_name: str, cluster_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Cluster"]: + """Lists the HDInsight cluster pools under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_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 Cluster or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) + + 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_by_cluster_pool_name_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster_pool_name.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_cluster_pool_name.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters" + } + + async def _resize_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_resize_request: Union[_models.ClusterResizeData, IO], + **kwargs: Any + ) -> Optional[_models.Cluster]: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Cluster]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_resize_request, (IOBase, bytes)): + _content = cluster_resize_request + else: + _json = self._serialize.body(cluster_resize_request, "ClusterResizeData") + + request = build_resize_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._resize_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Cluster", pipeline_response) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _resize_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/resize" + } + + @overload + async def begin_resize( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_resize_request: _models.ClusterResizeData, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Resize an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_resize_request: Resize a cluster. Required. + :type cluster_resize_request: ~azure.mgmt.hdinsightonaks.models.ClusterResizeData + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_resize( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_resize_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Resize an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_resize_request: Resize a cluster. Required. + :type cluster_resize_request: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_resize( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_resize_request: Union[_models.ClusterResizeData, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Resize an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_resize_request: Resize a cluster. Is either a ClusterResizeData type or a IO + type. Required. + :type cluster_resize_request: ~azure.mgmt.hdinsightonaks.models.ClusterResizeData 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._resize_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + cluster_resize_request=cluster_resize_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Cluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_resize.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/resize" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> _models.Cluster: + """Gets a HDInsight cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.Cluster + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Cluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + async def _create_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + hd_insight_cluster: Union[_models.Cluster, IO], + **kwargs: Any + ) -> _models.Cluster: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(hd_insight_cluster, (IOBase, bytes)): + _content = hd_insight_cluster + else: + _json = self._serialize.body(hd_insight_cluster, "Cluster") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Cluster", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Cluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + hd_insight_cluster: _models.Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Creates a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param hd_insight_cluster: The cluster to create. Required. + :type hd_insight_cluster: ~azure.mgmt.hdinsightonaks.models.Cluster + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + hd_insight_cluster: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Creates a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param hd_insight_cluster: The cluster to create. Required. + :type hd_insight_cluster: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + hd_insight_cluster: Union[_models.Cluster, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Creates a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param hd_insight_cluster: The cluster to create. Is either a Cluster type or a IO type. + Required. + :type hd_insight_cluster: ~azure.mgmt.hdinsightonaks.models.Cluster 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + hd_insight_cluster=hd_insight_cluster, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Cluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + async def _update_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_patch_request: Union[_models.ClusterPatch, IO], + **kwargs: Any + ) -> _models.Cluster: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_patch_request, (IOBase, bytes)): + _content = cluster_patch_request + else: + _json = self._serialize.body(cluster_patch_request, "ClusterPatch") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Cluster", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Cluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_patch_request: _models.ClusterPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Updates an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_patch_request: Patch a cluster. Required. + :type cluster_patch_request: ~azure.mgmt.hdinsightonaks.models.ClusterPatch + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_patch_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Updates an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_patch_request: Patch a cluster. Required. + :type cluster_patch_request: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_patch_request: Union[_models.ClusterPatch, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Updates an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_patch_request: Patch a cluster. Is either a ClusterPatch type or a IO type. + Required. + :type cluster_patch_request: ~azure.mgmt.hdinsightonaks.models.ClusterPatch 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + cluster_patch_request=cluster_patch_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Cluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> None: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + @distributed_trace + def list_service_configs( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServiceConfigResult"]: + """Lists the config dump of all services running in cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceConfigResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.ServiceConfigResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServiceConfigListResult] = kwargs.pop("cls", None) + + 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_service_configs_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_service_configs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceConfigListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_service_configs.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/serviceConfigs" + } + + @distributed_trace + def list_instance_views( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ClusterInstanceViewResult"]: + """Lists the lists of instance views. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterInstanceViewResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterInstanceViewsResult] = kwargs.pop("cls", None) + + 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_instance_views_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_instance_views.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterInstanceViewsResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_instance_views.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/instanceViews" + } + + @distributed_trace_async + async def get_instance_view( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> _models.ClusterInstanceViewResult: + """Gets the status of a cluster instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClusterInstanceViewResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewResult + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterInstanceViewResult] = kwargs.pop("cls", None) + + request = build_get_instance_view_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_instance_view.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ClusterInstanceViewResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_instance_view.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/instanceViews/default" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_locations_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_locations_operations.py new file mode 100644 index 000000000000..e09bc539cf04 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_locations_operations.py @@ -0,0 +1,176 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +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_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._locations_operations import build_check_name_availability_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.aio.HDInsightOnAksMgmtClient`'s + :attr:`locations` 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") + + @overload + async def check_name_availability( + self, + location: str, + name_availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityResult: + """Check the availability of the resource name. + + :param location: The name of the Azure region. Required. + :type location: str + :param name_availability_parameters: The name and type of the resource. Required. + :type name_availability_parameters: + ~azure.mgmt.hdinsightonaks.models.NameAvailabilityParameters + :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: NameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.NameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, name_availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityResult: + """Check the availability of the resource name. + + :param location: The name of the Azure region. Required. + :type location: str + :param name_availability_parameters: The name and type of the resource. Required. + :type name_availability_parameters: 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: NameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.NameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, name_availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailabilityResult: + """Check the availability of the resource name. + + :param location: The name of the Azure region. Required. + :type location: str + :param name_availability_parameters: The name and type of the resource. Is either a + NameAvailabilityParameters type or a IO type. Required. + :type name_availability_parameters: + ~azure.mgmt.hdinsightonaks.models.NameAvailabilityParameters 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: NameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.NameAvailabilityResult + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(name_availability_parameters, (IOBase, bytes)): + _content = name_availability_parameters + else: + _json = self._serialize.body(name_availability_parameters, "NameAvailabilityParameters") + + request = build_check_name_availability_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/checkNameAvailability" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_operations.py new file mode 100644 index 000000000000..6a78e749cb03 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_operations.py @@ -0,0 +1,133 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.aio.HDInsightOnAksMgmtClient`'s + :attr:`operations` 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 + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Returns list of operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsightonaks.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + 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( + 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) + + 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) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.HDInsight/operations"} diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/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/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/__init__.py new file mode 100644 index 000000000000..816bff59fdd2 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/__init__.py @@ -0,0 +1,231 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AksClusterProfile +from ._models_py3 import AksClusterProfileAksClusterAgentPoolIdentityProfile +from ._models_py3 import AuthorizationProfile +from ._models_py3 import AutoscaleProfile +from ._models_py3 import CatalogOptions +from ._models_py3 import Cluster +from ._models_py3 import ClusterComponentsItem +from ._models_py3 import ClusterConfigFile +from ._models_py3 import ClusterInstanceViewProperties +from ._models_py3 import ClusterInstanceViewPropertiesStatus +from ._models_py3 import ClusterInstanceViewResult +from ._models_py3 import ClusterInstanceViewResultProperties +from ._models_py3 import ClusterInstanceViewStatus +from ._models_py3 import ClusterInstanceViewsResult +from ._models_py3 import ClusterJob +from ._models_py3 import ClusterJobList +from ._models_py3 import ClusterJobProperties +from ._models_py3 import ClusterListResult +from ._models_py3 import ClusterLogAnalyticsApplicationLogs +from ._models_py3 import ClusterLogAnalyticsProfile +from ._models_py3 import ClusterPatch +from ._models_py3 import ClusterPool +from ._models_py3 import ClusterPoolComputeProfile +from ._models_py3 import ClusterPoolListResult +from ._models_py3 import ClusterPoolLogAnalyticsProfile +from ._models_py3 import ClusterPoolNetworkProfile +from ._models_py3 import ClusterPoolProfile +from ._models_py3 import ClusterPoolResourcePropertiesAksClusterProfile +from ._models_py3 import ClusterPoolResourcePropertiesClusterPoolProfile +from ._models_py3 import ClusterPoolResourcePropertiesComputeProfile +from ._models_py3 import ClusterPoolResourcePropertiesLogAnalyticsProfile +from ._models_py3 import ClusterPoolResourcePropertiesNetworkProfile +from ._models_py3 import ClusterPoolVersion +from ._models_py3 import ClusterPoolVersionsListResult +from ._models_py3 import ClusterProfile +from ._models_py3 import ClusterPrometheusProfile +from ._models_py3 import ClusterResizeData +from ._models_py3 import ClusterServiceConfig +from ._models_py3 import ClusterServiceConfigsProfile +from ._models_py3 import ClusterVersion +from ._models_py3 import ClusterVersionsListResult +from ._models_py3 import ComparisonRule +from ._models_py3 import ComputeProfile +from ._models_py3 import ComputeResourceDefinition +from ._models_py3 import ConnectivityProfile +from ._models_py3 import ConnectivityProfileWeb +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import FlinkCatalogOptions +from ._models_py3 import FlinkHiveCatalogOption +from ._models_py3 import FlinkJobProperties +from ._models_py3 import FlinkProfile +from ._models_py3 import FlinkStorageProfile +from ._models_py3 import HiveCatalogOption +from ._models_py3 import IdentityProfile +from ._models_py3 import LoadBasedConfig +from ._models_py3 import NameAvailabilityParameters +from ._models_py3 import NameAvailabilityResult +from ._models_py3 import NodeProfile +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import ScalingRule +from ._models_py3 import Schedule +from ._models_py3 import ScheduleBasedConfig +from ._models_py3 import ScriptActionProfile +from ._models_py3 import SecretReference +from ._models_py3 import SecretsProfile +from ._models_py3 import ServiceConfigListResult +from ._models_py3 import ServiceConfigListResultProperties +from ._models_py3 import ServiceConfigListResultValueEntity +from ._models_py3 import ServiceConfigResult +from ._models_py3 import ServiceConfigResultProperties +from ._models_py3 import ServiceStatus +from ._models_py3 import SparkMetastoreSpec +from ._models_py3 import SparkProfile +from ._models_py3 import SparkUserPlugin +from ._models_py3 import SparkUserPlugins +from ._models_py3 import SshConnectivityEndpoint +from ._models_py3 import SshProfile +from ._models_py3 import SystemData +from ._models_py3 import TagsObject +from ._models_py3 import TrackedResource +from ._models_py3 import TrinoCoordinator +from ._models_py3 import TrinoProfile +from ._models_py3 import TrinoTelemetryConfig +from ._models_py3 import TrinoUserPlugin +from ._models_py3 import TrinoUserPlugins +from ._models_py3 import TrinoUserTelemetry +from ._models_py3 import TrinoWorker +from ._models_py3 import UpdatableClusterProfile +from ._models_py3 import WebConnectivityEndpoint + +from ._hd_insight_on_aks_mgmt_client_enums import Action +from ._hd_insight_on_aks_mgmt_client_enums import ActionType +from ._hd_insight_on_aks_mgmt_client_enums import AutoscaleType +from ._hd_insight_on_aks_mgmt_client_enums import ComparisonOperator +from ._hd_insight_on_aks_mgmt_client_enums import ContentEncoding +from ._hd_insight_on_aks_mgmt_client_enums import CreatedByType +from ._hd_insight_on_aks_mgmt_client_enums import JobType +from ._hd_insight_on_aks_mgmt_client_enums import KeyVaultObjectType +from ._hd_insight_on_aks_mgmt_client_enums import Origin +from ._hd_insight_on_aks_mgmt_client_enums import ProvisioningStatus +from ._hd_insight_on_aks_mgmt_client_enums import ScaleActionType +from ._hd_insight_on_aks_mgmt_client_enums import ScheduleDay +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AksClusterProfile", + "AksClusterProfileAksClusterAgentPoolIdentityProfile", + "AuthorizationProfile", + "AutoscaleProfile", + "CatalogOptions", + "Cluster", + "ClusterComponentsItem", + "ClusterConfigFile", + "ClusterInstanceViewProperties", + "ClusterInstanceViewPropertiesStatus", + "ClusterInstanceViewResult", + "ClusterInstanceViewResultProperties", + "ClusterInstanceViewStatus", + "ClusterInstanceViewsResult", + "ClusterJob", + "ClusterJobList", + "ClusterJobProperties", + "ClusterListResult", + "ClusterLogAnalyticsApplicationLogs", + "ClusterLogAnalyticsProfile", + "ClusterPatch", + "ClusterPool", + "ClusterPoolComputeProfile", + "ClusterPoolListResult", + "ClusterPoolLogAnalyticsProfile", + "ClusterPoolNetworkProfile", + "ClusterPoolProfile", + "ClusterPoolResourcePropertiesAksClusterProfile", + "ClusterPoolResourcePropertiesClusterPoolProfile", + "ClusterPoolResourcePropertiesComputeProfile", + "ClusterPoolResourcePropertiesLogAnalyticsProfile", + "ClusterPoolResourcePropertiesNetworkProfile", + "ClusterPoolVersion", + "ClusterPoolVersionsListResult", + "ClusterProfile", + "ClusterPrometheusProfile", + "ClusterResizeData", + "ClusterServiceConfig", + "ClusterServiceConfigsProfile", + "ClusterVersion", + "ClusterVersionsListResult", + "ComparisonRule", + "ComputeProfile", + "ComputeResourceDefinition", + "ConnectivityProfile", + "ConnectivityProfileWeb", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "FlinkCatalogOptions", + "FlinkHiveCatalogOption", + "FlinkJobProperties", + "FlinkProfile", + "FlinkStorageProfile", + "HiveCatalogOption", + "IdentityProfile", + "LoadBasedConfig", + "NameAvailabilityParameters", + "NameAvailabilityResult", + "NodeProfile", + "Operation", + "OperationDisplay", + "OperationListResult", + "ProxyResource", + "Resource", + "ScalingRule", + "Schedule", + "ScheduleBasedConfig", + "ScriptActionProfile", + "SecretReference", + "SecretsProfile", + "ServiceConfigListResult", + "ServiceConfigListResultProperties", + "ServiceConfigListResultValueEntity", + "ServiceConfigResult", + "ServiceConfigResultProperties", + "ServiceStatus", + "SparkMetastoreSpec", + "SparkProfile", + "SparkUserPlugin", + "SparkUserPlugins", + "SshConnectivityEndpoint", + "SshProfile", + "SystemData", + "TagsObject", + "TrackedResource", + "TrinoCoordinator", + "TrinoProfile", + "TrinoTelemetryConfig", + "TrinoUserPlugin", + "TrinoUserPlugins", + "TrinoUserTelemetry", + "TrinoWorker", + "UpdatableClusterProfile", + "WebConnectivityEndpoint", + "Action", + "ActionType", + "AutoscaleType", + "ComparisonOperator", + "ContentEncoding", + "CreatedByType", + "JobType", + "KeyVaultObjectType", + "Origin", + "ProvisioningStatus", + "ScaleActionType", + "ScheduleDay", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_hd_insight_on_aks_mgmt_client_enums.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_hd_insight_on_aks_mgmt_client_enums.py new file mode 100644 index 000000000000..cd4fd682c917 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_hd_insight_on_aks_mgmt_client_enums.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A string property that indicates the action to be performed on the Flink job. It can have one + of the following enum values => NEW, UPDATE, STATELESS_UPDATE, STOP, START, CANCEL, SAVEPOINT, + LIST_SAVEPOINT, or DELETE. + """ + + NEW = "NEW" + UPDATE = "UPDATE" + STATELESS_UPDATE = "STATELESS_UPDATE" + STOP = "STOP" + START = "START" + CANCEL = "CANCEL" + SAVEPOINT = "SAVEPOINT" + LIST_SAVEPOINT = "LIST_SAVEPOINT" + DELETE = "DELETE" + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + +class AutoscaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """User to specify which type of Autoscale to be implemented - Scheduled Based or Load Based.""" + + SCHEDULE_BASED = "ScheduleBased" + LOAD_BASED = "LoadBased" + + +class ComparisonOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The comparison operator.""" + + GREATER_THAN = "greaterThan" + GREATER_THAN_OR_EQUAL = "greaterThanOrEqual" + LESS_THAN = "lessThan" + LESS_THAN_OR_EQUAL = "lessThanOrEqual" + + +class ContentEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property indicates if the content is encoded and is case-insensitive. Please set the value + to base64 if the content is base64 encoded. Set it to none or skip it if the content is plain + text. + """ + + BASE64 = "Base64" + NONE = "None" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of cluster job.""" + + FLINK_JOB = "FlinkJob" + + +class KeyVaultObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of key vault object: secret, key or certificate.""" + + KEY = "Key" + SECRET = "Secret" + CERTIFICATE = "Certificate" + + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + + +class ProvisioningStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" + + ACCEPTED = "Accepted" + SUCCEEDED = "Succeeded" + CANCELED = "Canceled" + FAILED = "Failed" + + +class ScaleActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action type.""" + + SCALEUP = "scaleup" + SCALEDOWN = "scaledown" + + +class ScheduleDay(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ScheduleDay.""" + + SUNDAY = "Sunday" + MONDAY = "Monday" + TUESDAY = "Tuesday" + WEDNESDAY = "Wednesday" + THURSDAY = "Thursday" + FRIDAY = "Friday" + SATURDAY = "Saturday" diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_models_py3.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_models_py3.py new file mode 100644 index 000000000000..9a9f440f91ec --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_models_py3.py @@ -0,0 +1,4396 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from .. import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class AksClusterProfile(_serialization.Model): + """Properties of the cluster pool underlying AKS cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar aks_cluster_resource_id: ARM Resource ID of the AKS cluster. + :vartype aks_cluster_resource_id: str + :ivar aks_cluster_agent_pool_identity_profile: Identity properties of the AKS cluster agentpool + MSI. + :vartype aks_cluster_agent_pool_identity_profile: + ~azure.mgmt.hdinsightonaks.models.AksClusterProfileAksClusterAgentPoolIdentityProfile + :ivar aks_version: AKS control plane and default node pool version of this ClusterPool. + :vartype aks_version: str + """ + + _validation = { + "aks_version": {"readonly": True}, + } + + _attribute_map = { + "aks_cluster_resource_id": {"key": "aksClusterResourceId", "type": "str"}, + "aks_cluster_agent_pool_identity_profile": { + "key": "aksClusterAgentPoolIdentityProfile", + "type": "AksClusterProfileAksClusterAgentPoolIdentityProfile", + }, + "aks_version": {"key": "aksVersion", "type": "str"}, + } + + def __init__( + self, + *, + aks_cluster_resource_id: Optional[str] = None, + aks_cluster_agent_pool_identity_profile: Optional[ + "_models.AksClusterProfileAksClusterAgentPoolIdentityProfile" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword aks_cluster_resource_id: ARM Resource ID of the AKS cluster. + :paramtype aks_cluster_resource_id: str + :keyword aks_cluster_agent_pool_identity_profile: Identity properties of the AKS cluster + agentpool MSI. + :paramtype aks_cluster_agent_pool_identity_profile: + ~azure.mgmt.hdinsightonaks.models.AksClusterProfileAksClusterAgentPoolIdentityProfile + """ + super().__init__(**kwargs) + self.aks_cluster_resource_id = aks_cluster_resource_id + self.aks_cluster_agent_pool_identity_profile = aks_cluster_agent_pool_identity_profile + self.aks_version = None + + +class IdentityProfile(_serialization.Model): + """Identity Profile with details of an MSI. + + All required parameters must be populated in order to send to Azure. + + :ivar msi_resource_id: ResourceId of the MSI. Required. + :vartype msi_resource_id: str + :ivar msi_client_id: ClientId of the MSI. Required. + :vartype msi_client_id: str + :ivar msi_object_id: ObjectId of the MSI. Required. + :vartype msi_object_id: str + """ + + _validation = { + "msi_resource_id": {"required": True}, + "msi_client_id": { + "required": True, + "pattern": r"^[{(]?[0-9A-Fa-f]{8}[-]?(?:[0-9A-Fa-f]{4}[-]?){3}[0-9A-Fa-f]{12}[)}]?$", + }, + "msi_object_id": { + "required": True, + "pattern": r"^[{(]?[0-9A-Fa-f]{8}[-]?(?:[0-9A-Fa-f]{4}[-]?){3}[0-9A-Fa-f]{12}[)}]?$", + }, + } + + _attribute_map = { + "msi_resource_id": {"key": "msiResourceId", "type": "str"}, + "msi_client_id": {"key": "msiClientId", "type": "str"}, + "msi_object_id": {"key": "msiObjectId", "type": "str"}, + } + + def __init__(self, *, msi_resource_id: str, msi_client_id: str, msi_object_id: str, **kwargs: Any) -> None: + """ + :keyword msi_resource_id: ResourceId of the MSI. Required. + :paramtype msi_resource_id: str + :keyword msi_client_id: ClientId of the MSI. Required. + :paramtype msi_client_id: str + :keyword msi_object_id: ObjectId of the MSI. Required. + :paramtype msi_object_id: str + """ + super().__init__(**kwargs) + self.msi_resource_id = msi_resource_id + self.msi_client_id = msi_client_id + self.msi_object_id = msi_object_id + + +class AksClusterProfileAksClusterAgentPoolIdentityProfile(IdentityProfile): + """Identity properties of the AKS cluster agentpool MSI. + + All required parameters must be populated in order to send to Azure. + + :ivar msi_resource_id: ResourceId of the MSI. Required. + :vartype msi_resource_id: str + :ivar msi_client_id: ClientId of the MSI. Required. + :vartype msi_client_id: str + :ivar msi_object_id: ObjectId of the MSI. Required. + :vartype msi_object_id: str + """ + + _validation = { + "msi_resource_id": {"required": True}, + "msi_client_id": { + "required": True, + "pattern": r"^[{(]?[0-9A-Fa-f]{8}[-]?(?:[0-9A-Fa-f]{4}[-]?){3}[0-9A-Fa-f]{12}[)}]?$", + }, + "msi_object_id": { + "required": True, + "pattern": r"^[{(]?[0-9A-Fa-f]{8}[-]?(?:[0-9A-Fa-f]{4}[-]?){3}[0-9A-Fa-f]{12}[)}]?$", + }, + } + + _attribute_map = { + "msi_resource_id": {"key": "msiResourceId", "type": "str"}, + "msi_client_id": {"key": "msiClientId", "type": "str"}, + "msi_object_id": {"key": "msiObjectId", "type": "str"}, + } + + def __init__(self, *, msi_resource_id: str, msi_client_id: str, msi_object_id: str, **kwargs: Any) -> None: + """ + :keyword msi_resource_id: ResourceId of the MSI. Required. + :paramtype msi_resource_id: str + :keyword msi_client_id: ClientId of the MSI. Required. + :paramtype msi_client_id: str + :keyword msi_object_id: ObjectId of the MSI. Required. + :paramtype msi_object_id: str + """ + super().__init__( + msi_resource_id=msi_resource_id, msi_client_id=msi_client_id, msi_object_id=msi_object_id, **kwargs + ) + + +class AuthorizationProfile(_serialization.Model): + """Authorization profile with details of AAD user Ids and group Ids authorized for data plane + access. + + :ivar user_ids: AAD user Ids authorized for data plane access. + :vartype user_ids: list[str] + :ivar group_ids: AAD group Ids authorized for data plane access. + :vartype group_ids: list[str] + """ + + _attribute_map = { + "user_ids": {"key": "userIds", "type": "[str]"}, + "group_ids": {"key": "groupIds", "type": "[str]"}, + } + + def __init__( + self, *, user_ids: Optional[List[str]] = None, group_ids: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """ + :keyword user_ids: AAD user Ids authorized for data plane access. + :paramtype user_ids: list[str] + :keyword group_ids: AAD group Ids authorized for data plane access. + :paramtype group_ids: list[str] + """ + super().__init__(**kwargs) + self.user_ids = user_ids + self.group_ids = group_ids + + +class AutoscaleProfile(_serialization.Model): + """This is the Autoscale profile for the cluster. This will allow customer to create cluster + enabled with Autoscale. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: This indicates whether auto scale is enabled on HDInsight on AKS cluster. + Required. + :vartype enabled: bool + :ivar graceful_decommission_timeout: This property is for graceful decommission timeout; It has + a default setting of 3600 seconds before forced shutdown takes place. This is the maximal time + to wait for running containers and applications to complete before transition a DECOMMISSIONING + node into DECOMMISSIONED. The default value is 3600 seconds. Negative value (like -1) is + handled as infinite timeout. + :vartype graceful_decommission_timeout: int + :ivar autoscale_type: User to specify which type of Autoscale to be implemented - Scheduled + Based or Load Based. Known values are: "ScheduleBased" and "LoadBased". + :vartype autoscale_type: str or ~azure.mgmt.hdinsightonaks.models.AutoscaleType + :ivar schedule_based_config: Profiles of schedule based Autoscale. + :vartype schedule_based_config: ~azure.mgmt.hdinsightonaks.models.ScheduleBasedConfig + :ivar load_based_config: Profiles of load based Autoscale. + :vartype load_based_config: ~azure.mgmt.hdinsightonaks.models.LoadBasedConfig + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "graceful_decommission_timeout": {"key": "gracefulDecommissionTimeout", "type": "int"}, + "autoscale_type": {"key": "autoscaleType", "type": "str"}, + "schedule_based_config": {"key": "scheduleBasedConfig", "type": "ScheduleBasedConfig"}, + "load_based_config": {"key": "loadBasedConfig", "type": "LoadBasedConfig"}, + } + + def __init__( + self, + *, + enabled: bool, + graceful_decommission_timeout: Optional[int] = None, + autoscale_type: Optional[Union[str, "_models.AutoscaleType"]] = None, + schedule_based_config: Optional["_models.ScheduleBasedConfig"] = None, + load_based_config: Optional["_models.LoadBasedConfig"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: This indicates whether auto scale is enabled on HDInsight on AKS cluster. + Required. + :paramtype enabled: bool + :keyword graceful_decommission_timeout: This property is for graceful decommission timeout; It + has a default setting of 3600 seconds before forced shutdown takes place. This is the maximal + time to wait for running containers and applications to complete before transition a + DECOMMISSIONING node into DECOMMISSIONED. The default value is 3600 seconds. Negative value + (like -1) is handled as infinite timeout. + :paramtype graceful_decommission_timeout: int + :keyword autoscale_type: User to specify which type of Autoscale to be implemented - Scheduled + Based or Load Based. Known values are: "ScheduleBased" and "LoadBased". + :paramtype autoscale_type: str or ~azure.mgmt.hdinsightonaks.models.AutoscaleType + :keyword schedule_based_config: Profiles of schedule based Autoscale. + :paramtype schedule_based_config: ~azure.mgmt.hdinsightonaks.models.ScheduleBasedConfig + :keyword load_based_config: Profiles of load based Autoscale. + :paramtype load_based_config: ~azure.mgmt.hdinsightonaks.models.LoadBasedConfig + """ + super().__init__(**kwargs) + self.enabled = enabled + self.graceful_decommission_timeout = graceful_decommission_timeout + self.autoscale_type = autoscale_type + self.schedule_based_config = schedule_based_config + self.load_based_config = load_based_config + + +class CatalogOptions(_serialization.Model): + """Trino cluster catalog options. + + :ivar hive: hive catalog options. + :vartype hive: list[~azure.mgmt.hdinsightonaks.models.HiveCatalogOption] + """ + + _attribute_map = { + "hive": {"key": "hive", "type": "[HiveCatalogOption]"}, + } + + def __init__(self, *, hive: Optional[List["_models.HiveCatalogOption"]] = None, **kwargs: Any) -> None: + """ + :keyword hive: hive catalog options. + :paramtype hive: list[~azure.mgmt.hdinsightonaks.models.HiveCatalogOption] + """ + super().__init__(**kwargs) + self.hive = hive + + +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. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes + """The cluster. + + 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. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Succeeded", "Canceled", and "Failed". + :vartype provisioning_state: str or ~azure.mgmt.hdinsightonaks.models.ProvisioningStatus + :ivar cluster_type: The type of cluster. + :vartype cluster_type: str + :ivar deployment_id: A unique id generated by the RP to identify the resource. + :vartype deployment_id: str + :ivar compute_profile: The compute profile. + :vartype compute_profile: ~azure.mgmt.hdinsightonaks.models.ComputeProfile + :ivar cluster_profile: Cluster profile. + :vartype cluster_profile: ~azure.mgmt.hdinsightonaks.models.ClusterProfile + :ivar status: Business status of the resource. + :vartype status: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "cluster_type": {"pattern": r"^[a-zA-Z][a-zA-Z0-9]{0,31}$"}, + "deployment_id": {"readonly": True}, + "status": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_type": {"key": "properties.clusterType", "type": "str"}, + "deployment_id": {"key": "properties.deploymentId", "type": "str"}, + "compute_profile": {"key": "properties.computeProfile", "type": "ComputeProfile"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "status": {"key": "properties.status", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + cluster_type: Optional[str] = None, + compute_profile: Optional["_models.ComputeProfile"] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword cluster_type: The type of cluster. + :paramtype cluster_type: str + :keyword compute_profile: The compute profile. + :paramtype compute_profile: ~azure.mgmt.hdinsightonaks.models.ComputeProfile + :keyword cluster_profile: Cluster profile. + :paramtype cluster_profile: ~azure.mgmt.hdinsightonaks.models.ClusterProfile + """ + super().__init__(tags=tags, location=location, **kwargs) + self.provisioning_state = None + self.cluster_type = cluster_type + self.deployment_id = None + self.compute_profile = compute_profile + self.cluster_profile = cluster_profile + self.status = None + + +class ClusterComponentsItem(_serialization.Model): + """ClusterComponentsItem. + + :ivar name: + :vartype name: str + :ivar version: + :vartype version: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, version: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: + :paramtype name: str + :keyword version: + :paramtype version: str + """ + super().__init__(**kwargs) + self.name = name + self.version = version + + +class ClusterConfigFile(_serialization.Model): + """Cluster configuration files. + + All required parameters must be populated in order to send to Azure. + + :ivar file_name: Configuration file name. Required. + :vartype file_name: str + :ivar content: Free form content of the entire configuration file. + :vartype content: str + :ivar encoding: This property indicates if the content is encoded and is case-insensitive. + Please set the value to base64 if the content is base64 encoded. Set it to none or skip it if + the content is plain text. Known values are: "Base64" and "None". + :vartype encoding: str or ~azure.mgmt.hdinsightonaks.models.ContentEncoding + :ivar path: Path of the config file if content is specified. + :vartype path: str + :ivar values: List of key value pairs + where key represents a valid service configuration name and value represents the value of the + config. + :vartype values: dict[str, str] + """ + + _validation = { + "file_name": {"required": True}, + } + + _attribute_map = { + "file_name": {"key": "fileName", "type": "str"}, + "content": {"key": "content", "type": "str"}, + "encoding": {"key": "encoding", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "values": {"key": "values", "type": "{str}"}, + } + + def __init__( + self, + *, + file_name: str, + content: Optional[str] = None, + encoding: Optional[Union[str, "_models.ContentEncoding"]] = None, + path: Optional[str] = None, + values: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword file_name: Configuration file name. Required. + :paramtype file_name: str + :keyword content: Free form content of the entire configuration file. + :paramtype content: str + :keyword encoding: This property indicates if the content is encoded and is case-insensitive. + Please set the value to base64 if the content is base64 encoded. Set it to none or skip it if + the content is plain text. Known values are: "Base64" and "None". + :paramtype encoding: str or ~azure.mgmt.hdinsightonaks.models.ContentEncoding + :keyword path: Path of the config file if content is specified. + :paramtype path: str + :keyword values: List of key value pairs + where key represents a valid service configuration name and value represents the value of the + config. + :paramtype values: dict[str, str] + """ + super().__init__(**kwargs) + self.file_name = file_name + self.content = content + self.encoding = encoding + self.path = path + self.values = values + + +class ClusterInstanceViewProperties(_serialization.Model): + """Cluster Instance View Properties. + + All required parameters must be populated in order to send to Azure. + + :ivar status: Status of the instance view. Required. + :vartype status: ~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewPropertiesStatus + :ivar service_statuses: List of statuses of relevant services that make up the HDInsight on aks + cluster to surface to the customer. Required. + :vartype service_statuses: list[~azure.mgmt.hdinsightonaks.models.ServiceStatus] + """ + + _validation = { + "status": {"required": True}, + "service_statuses": {"required": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "ClusterInstanceViewPropertiesStatus"}, + "service_statuses": {"key": "serviceStatuses", "type": "[ServiceStatus]"}, + } + + def __init__( + self, + *, + status: "_models.ClusterInstanceViewPropertiesStatus", + service_statuses: List["_models.ServiceStatus"], + **kwargs: Any + ) -> None: + """ + :keyword status: Status of the instance view. Required. + :paramtype status: ~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewPropertiesStatus + :keyword service_statuses: List of statuses of relevant services that make up the HDInsight on + aks cluster to surface to the customer. Required. + :paramtype service_statuses: list[~azure.mgmt.hdinsightonaks.models.ServiceStatus] + """ + super().__init__(**kwargs) + self.status = status + self.service_statuses = service_statuses + + +class ClusterInstanceViewStatus(_serialization.Model): + """Status of the instance view. + + All required parameters must be populated in order to send to Azure. + + :ivar ready: The cluster ready status. Required. + :vartype ready: str + :ivar reason: The status reason. + :vartype reason: str + :ivar message: The additional message. + :vartype message: str + """ + + _validation = { + "ready": {"required": True}, + } + + _attribute_map = { + "ready": {"key": "ready", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__( + self, *, ready: str, reason: Optional[str] = None, message: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword ready: The cluster ready status. Required. + :paramtype ready: str + :keyword reason: The status reason. + :paramtype reason: str + :keyword message: The additional message. + :paramtype message: str + """ + super().__init__(**kwargs) + self.ready = ready + self.reason = reason + self.message = message + + +class ClusterInstanceViewPropertiesStatus(ClusterInstanceViewStatus): + """Status of the instance view. + + All required parameters must be populated in order to send to Azure. + + :ivar ready: The cluster ready status. Required. + :vartype ready: str + :ivar reason: The status reason. + :vartype reason: str + :ivar message: The additional message. + :vartype message: str + """ + + _validation = { + "ready": {"required": True}, + } + + _attribute_map = { + "ready": {"key": "ready", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__( + self, *, ready: str, reason: Optional[str] = None, message: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword ready: The cluster ready status. Required. + :paramtype ready: str + :keyword reason: The status reason. + :paramtype reason: str + :keyword message: The additional message. + :paramtype message: str + """ + super().__init__(ready=ready, reason=reason, message=message, **kwargs) + + +class ClusterInstanceViewResult(_serialization.Model): + """Cluster Instance View. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the instance view. Required. + :vartype name: str + :ivar status: Status of the instance view. Required. + :vartype status: ~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewPropertiesStatus + :ivar service_statuses: List of statuses of relevant services that make up the HDInsight on aks + cluster to surface to the customer. Required. + :vartype service_statuses: list[~azure.mgmt.hdinsightonaks.models.ServiceStatus] + """ + + _validation = { + "name": {"required": True}, + "status": {"required": True}, + "service_statuses": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "status": {"key": "properties.status", "type": "ClusterInstanceViewPropertiesStatus"}, + "service_statuses": {"key": "properties.serviceStatuses", "type": "[ServiceStatus]"}, + } + + def __init__( + self, + *, + name: str, + status: "_models.ClusterInstanceViewPropertiesStatus", + service_statuses: List["_models.ServiceStatus"], + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the instance view. Required. + :paramtype name: str + :keyword status: Status of the instance view. Required. + :paramtype status: ~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewPropertiesStatus + :keyword service_statuses: List of statuses of relevant services that make up the HDInsight on + aks cluster to surface to the customer. Required. + :paramtype service_statuses: list[~azure.mgmt.hdinsightonaks.models.ServiceStatus] + """ + super().__init__(**kwargs) + self.name = name + self.status = status + self.service_statuses = service_statuses + + +class ClusterInstanceViewResultProperties(ClusterInstanceViewProperties): + """Properties of the instance view. + + All required parameters must be populated in order to send to Azure. + + :ivar status: Status of the instance view. Required. + :vartype status: ~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewPropertiesStatus + :ivar service_statuses: List of statuses of relevant services that make up the HDInsight on aks + cluster to surface to the customer. Required. + :vartype service_statuses: list[~azure.mgmt.hdinsightonaks.models.ServiceStatus] + """ + + _validation = { + "status": {"required": True}, + "service_statuses": {"required": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "ClusterInstanceViewPropertiesStatus"}, + "service_statuses": {"key": "serviceStatuses", "type": "[ServiceStatus]"}, + } + + def __init__( + self, + *, + status: "_models.ClusterInstanceViewPropertiesStatus", + service_statuses: List["_models.ServiceStatus"], + **kwargs: Any + ) -> None: + """ + :keyword status: Status of the instance view. Required. + :paramtype status: ~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewPropertiesStatus + :keyword service_statuses: List of statuses of relevant services that make up the HDInsight on + aks cluster to surface to the customer. Required. + :paramtype service_statuses: list[~azure.mgmt.hdinsightonaks.models.ServiceStatus] + """ + super().__init__(status=status, service_statuses=service_statuses, **kwargs) + + +class ClusterInstanceViewsResult(_serialization.Model): + """The instance view of a HDInsight Cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Cluster instance view array. + :vartype value: list[~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewResult] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ClusterInstanceViewResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ClusterInstanceViewResult"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Cluster instance view array. + :paramtype value: list[~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewResult] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class ClusterJob(ProxyResource): + """Cluster job. + + 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. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.models.SystemData + :ivar properties: Properties of cluster job. Required. + :vartype properties: ~azure.mgmt.hdinsightonaks.models.ClusterJobProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ClusterJobProperties"}, + } + + def __init__(self, *, properties: "_models.ClusterJobProperties", **kwargs: Any) -> None: + """ + :keyword properties: Properties of cluster job. Required. + :paramtype properties: ~azure.mgmt.hdinsightonaks.models.ClusterJobProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ClusterJobList(_serialization.Model): + """Collection of cluster job. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Collection of cluster job. Required. + :vartype value: list[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :ivar next_link: The Url of next result page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ClusterJob]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.ClusterJob"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: Collection of cluster job. Required. + :paramtype value: list[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :keyword next_link: The Url of next result page. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ClusterJobProperties(_serialization.Model): + """Properties of cluster job. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FlinkJobProperties + + All required parameters must be populated in order to send to Azure. + + :ivar job_type: Type of cluster job. Required. "FlinkJob" + :vartype job_type: str or ~azure.mgmt.hdinsightonaks.models.JobType + """ + + _validation = { + "job_type": {"required": True}, + } + + _attribute_map = { + "job_type": {"key": "jobType", "type": "str"}, + } + + _subtype_map = {"job_type": {"FlinkJob": "FlinkJobProperties"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.job_type: Optional[str] = None + + +class ClusterListResult(_serialization.Model): + """The list cluster operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of clusters. + :vartype value: list[~azure.mgmt.hdinsightonaks.models.Cluster] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Cluster]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Cluster"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of clusters. + :paramtype value: list[~azure.mgmt.hdinsightonaks.models.Cluster] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ClusterLogAnalyticsApplicationLogs(_serialization.Model): + """Collection of logs to be enabled or disabled for log analytics. + + :ivar std_out_enabled: True if stdout is enabled, otherwise false. + :vartype std_out_enabled: bool + :ivar std_error_enabled: True if stderror is enabled, otherwise false. + :vartype std_error_enabled: bool + """ + + _attribute_map = { + "std_out_enabled": {"key": "stdOutEnabled", "type": "bool"}, + "std_error_enabled": {"key": "stdErrorEnabled", "type": "bool"}, + } + + def __init__( + self, *, std_out_enabled: Optional[bool] = None, std_error_enabled: Optional[bool] = None, **kwargs: Any + ) -> None: + """ + :keyword std_out_enabled: True if stdout is enabled, otherwise false. + :paramtype std_out_enabled: bool + :keyword std_error_enabled: True if stderror is enabled, otherwise false. + :paramtype std_error_enabled: bool + """ + super().__init__(**kwargs) + self.std_out_enabled = std_out_enabled + self.std_error_enabled = std_error_enabled + + +class ClusterLogAnalyticsProfile(_serialization.Model): + """Cluster log analytics profile to enable or disable OMS agent for cluster. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: True if log analytics is enabled for the cluster, otherwise false. Required. + :vartype enabled: bool + :ivar application_logs: Collection of logs to be enabled or disabled for log analytics. + :vartype application_logs: ~azure.mgmt.hdinsightonaks.models.ClusterLogAnalyticsApplicationLogs + :ivar metrics_enabled: True if metrics are enabled, otherwise false. + :vartype metrics_enabled: bool + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "application_logs": {"key": "applicationLogs", "type": "ClusterLogAnalyticsApplicationLogs"}, + "metrics_enabled": {"key": "metricsEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + enabled: bool, + application_logs: Optional["_models.ClusterLogAnalyticsApplicationLogs"] = None, + metrics_enabled: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: True if log analytics is enabled for the cluster, otherwise false. Required. + :paramtype enabled: bool + :keyword application_logs: Collection of logs to be enabled or disabled for log analytics. + :paramtype application_logs: + ~azure.mgmt.hdinsightonaks.models.ClusterLogAnalyticsApplicationLogs + :keyword metrics_enabled: True if metrics are enabled, otherwise false. + :paramtype metrics_enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + self.application_logs = application_logs + self.metrics_enabled = metrics_enabled + + +class ClusterPatch(TrackedResource): + """The patch for a cluster. + + 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. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar cluster_profile: Cluster resource patch properties. + :vartype cluster_profile: ~azure.mgmt.hdinsightonaks.models.UpdatableClusterProfile + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "UpdatableClusterProfile"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + cluster_profile: Optional["_models.UpdatableClusterProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword cluster_profile: Cluster resource patch properties. + :paramtype cluster_profile: ~azure.mgmt.hdinsightonaks.models.UpdatableClusterProfile + """ + super().__init__(tags=tags, location=location, **kwargs) + self.cluster_profile = cluster_profile + + +class ClusterPool(TrackedResource): # pylint: disable=too-many-instance-attributes + """Cluster pool. + + 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. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Accepted", + "Succeeded", "Canceled", and "Failed". + :vartype provisioning_state: str or ~azure.mgmt.hdinsightonaks.models.ProvisioningStatus + :ivar deployment_id: A unique id generated by the RP to identify the resource. + :vartype deployment_id: str + :ivar managed_resource_group_name: A resource group created by RP, to hold the resources + created by RP on-behalf of customers. It will also be used to generate + aksManagedResourceGroupName by pattern: MC\ *{managedResourceGroupName}*\ + {clusterPoolName}_{region}. Please make sure it meets resource group name restriction. + :vartype managed_resource_group_name: str + :ivar aks_managed_resource_group_name: A resource group created by AKS, to hold the + infrastructure resources created by AKS on-behalf of customers. It is generated by cluster pool + name and managed resource group name by pattern: MC\ *{managedResourceGroupName}*\ + {clusterPoolName}_{region}. + :vartype aks_managed_resource_group_name: str + :ivar cluster_pool_profile: CLuster pool profile. + :vartype cluster_pool_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesClusterPoolProfile + :ivar compute_profile: CLuster pool compute profile. + :vartype compute_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesComputeProfile + :ivar aks_cluster_profile: Properties of underlying AKS cluster. + :vartype aks_cluster_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesAksClusterProfile + :ivar network_profile: Cluster pool network profile. + :vartype network_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesNetworkProfile + :ivar log_analytics_profile: Cluster pool log analytics profile to enable OMS agent for AKS + cluster. + :vartype log_analytics_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesLogAnalyticsProfile + :ivar status: Business status of the resource. + :vartype status: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "deployment_id": {"readonly": True}, + "managed_resource_group_name": {"max_length": 40, "min_length": 1}, + "aks_managed_resource_group_name": {"readonly": True}, + "aks_cluster_profile": {"readonly": True}, + "status": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "deployment_id": {"key": "properties.deploymentId", "type": "str"}, + "managed_resource_group_name": {"key": "properties.managedResourceGroupName", "type": "str"}, + "aks_managed_resource_group_name": {"key": "properties.aksManagedResourceGroupName", "type": "str"}, + "cluster_pool_profile": { + "key": "properties.clusterPoolProfile", + "type": "ClusterPoolResourcePropertiesClusterPoolProfile", + }, + "compute_profile": {"key": "properties.computeProfile", "type": "ClusterPoolResourcePropertiesComputeProfile"}, + "aks_cluster_profile": { + "key": "properties.aksClusterProfile", + "type": "ClusterPoolResourcePropertiesAksClusterProfile", + }, + "network_profile": {"key": "properties.networkProfile", "type": "ClusterPoolResourcePropertiesNetworkProfile"}, + "log_analytics_profile": { + "key": "properties.logAnalyticsProfile", + "type": "ClusterPoolResourcePropertiesLogAnalyticsProfile", + }, + "status": {"key": "properties.status", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + managed_resource_group_name: Optional[str] = None, + cluster_pool_profile: Optional["_models.ClusterPoolResourcePropertiesClusterPoolProfile"] = None, + compute_profile: Optional["_models.ClusterPoolResourcePropertiesComputeProfile"] = None, + network_profile: Optional["_models.ClusterPoolResourcePropertiesNetworkProfile"] = None, + log_analytics_profile: Optional["_models.ClusterPoolResourcePropertiesLogAnalyticsProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword managed_resource_group_name: A resource group created by RP, to hold the resources + created by RP on-behalf of customers. It will also be used to generate + aksManagedResourceGroupName by pattern: MC\ *{managedResourceGroupName}*\ + {clusterPoolName}_{region}. Please make sure it meets resource group name restriction. + :paramtype managed_resource_group_name: str + :keyword cluster_pool_profile: CLuster pool profile. + :paramtype cluster_pool_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesClusterPoolProfile + :keyword compute_profile: CLuster pool compute profile. + :paramtype compute_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesComputeProfile + :keyword network_profile: Cluster pool network profile. + :paramtype network_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesNetworkProfile + :keyword log_analytics_profile: Cluster pool log analytics profile to enable OMS agent for AKS + cluster. + :paramtype log_analytics_profile: + ~azure.mgmt.hdinsightonaks.models.ClusterPoolResourcePropertiesLogAnalyticsProfile + """ + super().__init__(tags=tags, location=location, **kwargs) + self.provisioning_state = None + self.deployment_id = None + self.managed_resource_group_name = managed_resource_group_name + self.aks_managed_resource_group_name = None + self.cluster_pool_profile = cluster_pool_profile + self.compute_profile = compute_profile + self.aks_cluster_profile = None + self.network_profile = network_profile + self.log_analytics_profile = log_analytics_profile + self.status = None + + +class ClusterPoolComputeProfile(_serialization.Model): + """Cluster pool compute profile. + + All required parameters must be populated in order to send to Azure. + + :ivar vm_size: The virtual machine SKU. Required. + :vartype vm_size: str + :ivar count: The number of virtual machines. + :vartype count: int + """ + + _validation = { + "vm_size": {"required": True, "pattern": r"^[a-zA-Z0-9_\-]{0,256}$"}, + "count": {"maximum": 10, "minimum": 3}, + } + + _attribute_map = { + "vm_size": {"key": "vmSize", "type": "str"}, + "count": {"key": "count", "type": "int"}, + } + + def __init__(self, *, vm_size: str, count: int = 3, **kwargs: Any) -> None: + """ + :keyword vm_size: The virtual machine SKU. Required. + :paramtype vm_size: str + :keyword count: The number of virtual machines. + :paramtype count: int + """ + super().__init__(**kwargs) + self.vm_size = vm_size + self.count = count + + +class ClusterPoolListResult(_serialization.Model): + """The list cluster pools operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of cluster pools. + :vartype value: list[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ClusterPool]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ClusterPool"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of cluster pools. + :paramtype value: list[~azure.mgmt.hdinsightonaks.models.ClusterPool] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ClusterPoolLogAnalyticsProfile(_serialization.Model): + """Cluster pool log analytics profile used to enable or disable OMS agent for AKS cluster. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: True if log analytics is enabled for cluster pool, otherwise false. Required. + :vartype enabled: bool + :ivar workspace_id: Log analytics workspace to associate with the OMS agent. + :vartype workspace_id: str + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + } + + def __init__(self, *, enabled: bool, workspace_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: True if log analytics is enabled for cluster pool, otherwise false. Required. + :paramtype enabled: bool + :keyword workspace_id: Log analytics workspace to associate with the OMS agent. + :paramtype workspace_id: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workspace_id = workspace_id + + +class ClusterPoolNetworkProfile(_serialization.Model): + """Cluster pool networking configuration. + + All required parameters must be populated in order to send to Azure. + + :ivar subnet_id: Cluster pool subnet resource id. Required. + :vartype subnet_id: str + """ + + _validation = { + "subnet_id": {"required": True}, + } + + _attribute_map = { + "subnet_id": {"key": "subnetId", "type": "str"}, + } + + def __init__(self, *, subnet_id: str, **kwargs: Any) -> None: + """ + :keyword subnet_id: Cluster pool subnet resource id. Required. + :paramtype subnet_id: str + """ + super().__init__(**kwargs) + self.subnet_id = subnet_id + + +class ClusterPoolProfile(_serialization.Model): + """Cluster pool profile. + + All required parameters must be populated in order to send to Azure. + + :ivar cluster_pool_version: Cluster pool version is a 2-part version. Required. + :vartype cluster_pool_version: str + """ + + _validation = { + "cluster_pool_version": {"required": True, "pattern": r"^(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})$"}, + } + + _attribute_map = { + "cluster_pool_version": {"key": "clusterPoolVersion", "type": "str"}, + } + + def __init__(self, *, cluster_pool_version: str, **kwargs: Any) -> None: + """ + :keyword cluster_pool_version: Cluster pool version is a 2-part version. Required. + :paramtype cluster_pool_version: str + """ + super().__init__(**kwargs) + self.cluster_pool_version = cluster_pool_version + + +class ClusterPoolResourcePropertiesAksClusterProfile(AksClusterProfile): + """Properties of underlying AKS cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar aks_cluster_resource_id: ARM Resource ID of the AKS cluster. + :vartype aks_cluster_resource_id: str + :ivar aks_cluster_agent_pool_identity_profile: Identity properties of the AKS cluster agentpool + MSI. + :vartype aks_cluster_agent_pool_identity_profile: + ~azure.mgmt.hdinsightonaks.models.AksClusterProfileAksClusterAgentPoolIdentityProfile + :ivar aks_version: AKS control plane and default node pool version of this ClusterPool. + :vartype aks_version: str + """ + + _validation = { + "aks_version": {"readonly": True}, + } + + _attribute_map = { + "aks_cluster_resource_id": {"key": "aksClusterResourceId", "type": "str"}, + "aks_cluster_agent_pool_identity_profile": { + "key": "aksClusterAgentPoolIdentityProfile", + "type": "AksClusterProfileAksClusterAgentPoolIdentityProfile", + }, + "aks_version": {"key": "aksVersion", "type": "str"}, + } + + def __init__( + self, + *, + aks_cluster_resource_id: Optional[str] = None, + aks_cluster_agent_pool_identity_profile: Optional[ + "_models.AksClusterProfileAksClusterAgentPoolIdentityProfile" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword aks_cluster_resource_id: ARM Resource ID of the AKS cluster. + :paramtype aks_cluster_resource_id: str + :keyword aks_cluster_agent_pool_identity_profile: Identity properties of the AKS cluster + agentpool MSI. + :paramtype aks_cluster_agent_pool_identity_profile: + ~azure.mgmt.hdinsightonaks.models.AksClusterProfileAksClusterAgentPoolIdentityProfile + """ + super().__init__( + aks_cluster_resource_id=aks_cluster_resource_id, + aks_cluster_agent_pool_identity_profile=aks_cluster_agent_pool_identity_profile, + **kwargs + ) + + +class ClusterPoolResourcePropertiesClusterPoolProfile(ClusterPoolProfile): + """CLuster pool profile. + + All required parameters must be populated in order to send to Azure. + + :ivar cluster_pool_version: Cluster pool version is a 2-part version. Required. + :vartype cluster_pool_version: str + """ + + _validation = { + "cluster_pool_version": {"required": True, "pattern": r"^(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})$"}, + } + + _attribute_map = { + "cluster_pool_version": {"key": "clusterPoolVersion", "type": "str"}, + } + + def __init__(self, *, cluster_pool_version: str, **kwargs: Any) -> None: + """ + :keyword cluster_pool_version: Cluster pool version is a 2-part version. Required. + :paramtype cluster_pool_version: str + """ + super().__init__(cluster_pool_version=cluster_pool_version, **kwargs) + + +class ClusterPoolResourcePropertiesComputeProfile(ClusterPoolComputeProfile): + """CLuster pool compute profile. + + All required parameters must be populated in order to send to Azure. + + :ivar vm_size: The virtual machine SKU. Required. + :vartype vm_size: str + :ivar count: The number of virtual machines. + :vartype count: int + """ + + _validation = { + "vm_size": {"required": True, "pattern": r"^[a-zA-Z0-9_\-]{0,256}$"}, + "count": {"maximum": 10, "minimum": 3}, + } + + _attribute_map = { + "vm_size": {"key": "vmSize", "type": "str"}, + "count": {"key": "count", "type": "int"}, + } + + def __init__(self, *, vm_size: str, count: int = 3, **kwargs: Any) -> None: + """ + :keyword vm_size: The virtual machine SKU. Required. + :paramtype vm_size: str + :keyword count: The number of virtual machines. + :paramtype count: int + """ + super().__init__(vm_size=vm_size, count=count, **kwargs) + + +class ClusterPoolResourcePropertiesLogAnalyticsProfile(ClusterPoolLogAnalyticsProfile): + """Cluster pool log analytics profile to enable OMS agent for AKS cluster. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: True if log analytics is enabled for cluster pool, otherwise false. Required. + :vartype enabled: bool + :ivar workspace_id: Log analytics workspace to associate with the OMS agent. + :vartype workspace_id: str + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + } + + def __init__(self, *, enabled: bool, workspace_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: True if log analytics is enabled for cluster pool, otherwise false. Required. + :paramtype enabled: bool + :keyword workspace_id: Log analytics workspace to associate with the OMS agent. + :paramtype workspace_id: str + """ + super().__init__(enabled=enabled, workspace_id=workspace_id, **kwargs) + + +class ClusterPoolResourcePropertiesNetworkProfile(ClusterPoolNetworkProfile): + """Cluster pool network profile. + + All required parameters must be populated in order to send to Azure. + + :ivar subnet_id: Cluster pool subnet resource id. Required. + :vartype subnet_id: str + """ + + _validation = { + "subnet_id": {"required": True}, + } + + _attribute_map = { + "subnet_id": {"key": "subnetId", "type": "str"}, + } + + def __init__(self, *, subnet_id: str, **kwargs: Any) -> None: + """ + :keyword subnet_id: Cluster pool subnet resource id. Required. + :paramtype subnet_id: str + """ + super().__init__(subnet_id=subnet_id, **kwargs) + + +class ClusterPoolVersion(ProxyResource): + """Available cluster pool version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.models.SystemData + :ivar cluster_pool_version: Cluster pool version is a 2-part version. + :vartype cluster_pool_version: str + :ivar aks_version: AKS version. + :vartype aks_version: str + :ivar is_preview: Indicate if this version is in preview or not. + :vartype is_preview: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "cluster_pool_version": {"pattern": r"^(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "cluster_pool_version": {"key": "properties.clusterPoolVersion", "type": "str"}, + "aks_version": {"key": "properties.aksVersion", "type": "str"}, + "is_preview": {"key": "properties.isPreview", "type": "bool"}, + } + + def __init__( + self, + *, + cluster_pool_version: Optional[str] = None, + aks_version: Optional[str] = None, + is_preview: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword cluster_pool_version: Cluster pool version is a 2-part version. + :paramtype cluster_pool_version: str + :keyword aks_version: AKS version. + :paramtype aks_version: str + :keyword is_preview: Indicate if this version is in preview or not. + :paramtype is_preview: bool + """ + super().__init__(**kwargs) + self.cluster_pool_version = cluster_pool_version + self.aks_version = aks_version + self.is_preview = is_preview + + +class ClusterPoolVersionsListResult(_serialization.Model): + """Represents a list of cluster pool versions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of cluster pool versions. + :vartype value: list[~azure.mgmt.hdinsightonaks.models.ClusterPoolVersion] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ClusterPoolVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ClusterPoolVersion"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of cluster pool versions. + :paramtype value: list[~azure.mgmt.hdinsightonaks.models.ClusterPoolVersion] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ClusterProfile(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Cluster profile. + + 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 cluster_version: Version with 3/4 part. Required. + :vartype cluster_version: str + :ivar oss_version: Version with three part. Required. + :vartype oss_version: str + :ivar components: Component list of this cluster type and version. + :vartype components: list[~azure.mgmt.hdinsightonaks.models.ClusterComponentsItem] + :ivar identity_profile: Identity Profile with details of an MSI. Required. + :vartype identity_profile: ~azure.mgmt.hdinsightonaks.models.IdentityProfile + :ivar authorization_profile: Authorization profile with details of AAD user Ids and group Ids + authorized for data plane access. Required. + :vartype authorization_profile: ~azure.mgmt.hdinsightonaks.models.AuthorizationProfile + :ivar secrets_profile: The cluster secret profile. + :vartype secrets_profile: ~azure.mgmt.hdinsightonaks.models.SecretsProfile + :ivar service_configs_profiles: The service configs profiles. + :vartype service_configs_profiles: + list[~azure.mgmt.hdinsightonaks.models.ClusterServiceConfigsProfile] + :ivar connectivity_profile: Cluster connectivity profile. + :vartype connectivity_profile: ~azure.mgmt.hdinsightonaks.models.ConnectivityProfile + :ivar log_analytics_profile: Cluster log analytics profile to enable or disable OMS agent for + cluster. + :vartype log_analytics_profile: ~azure.mgmt.hdinsightonaks.models.ClusterLogAnalyticsProfile + :ivar prometheus_profile: Cluster Prometheus profile. + :vartype prometheus_profile: ~azure.mgmt.hdinsightonaks.models.ClusterPrometheusProfile + :ivar ssh_profile: Ssh profile for the cluster. + :vartype ssh_profile: ~azure.mgmt.hdinsightonaks.models.SshProfile + :ivar autoscale_profile: This is the Autoscale profile for the cluster. This will allow + customer to create cluster enabled with Autoscale. + :vartype autoscale_profile: ~azure.mgmt.hdinsightonaks.models.AutoscaleProfile + :ivar kafka_profile: Kafka cluster profile. + :vartype kafka_profile: dict[str, any] + :ivar trino_profile: Trino Cluster profile. + :vartype trino_profile: ~azure.mgmt.hdinsightonaks.models.TrinoProfile + :ivar llap_profile: LLAP cluster profile. + :vartype llap_profile: dict[str, any] + :ivar flink_profile: The Flink cluster profile. + :vartype flink_profile: ~azure.mgmt.hdinsightonaks.models.FlinkProfile + :ivar spark_profile: The spark cluster profile. + :vartype spark_profile: ~azure.mgmt.hdinsightonaks.models.SparkProfile + :ivar stub_profile: Stub cluster profile. + :vartype stub_profile: dict[str, any] + :ivar script_action_profiles: The script action profile list. + :vartype script_action_profiles: list[~azure.mgmt.hdinsightonaks.models.ScriptActionProfile] + """ + + _validation = { + "cluster_version": { + "required": True, + "pattern": r"^(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})(?:\.(0|[1-9][0-9]{0,18}))?$", + }, + "oss_version": { + "required": True, + "pattern": r"^(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})$", + }, + "components": {"readonly": True}, + "identity_profile": {"required": True}, + "authorization_profile": {"required": True}, + "connectivity_profile": {"readonly": True}, + } + + _attribute_map = { + "cluster_version": {"key": "clusterVersion", "type": "str"}, + "oss_version": {"key": "ossVersion", "type": "str"}, + "components": {"key": "components", "type": "[ClusterComponentsItem]"}, + "identity_profile": {"key": "identityProfile", "type": "IdentityProfile"}, + "authorization_profile": {"key": "authorizationProfile", "type": "AuthorizationProfile"}, + "secrets_profile": {"key": "secretsProfile", "type": "SecretsProfile"}, + "service_configs_profiles": {"key": "serviceConfigsProfiles", "type": "[ClusterServiceConfigsProfile]"}, + "connectivity_profile": {"key": "connectivityProfile", "type": "ConnectivityProfile"}, + "log_analytics_profile": {"key": "logAnalyticsProfile", "type": "ClusterLogAnalyticsProfile"}, + "prometheus_profile": {"key": "prometheusProfile", "type": "ClusterPrometheusProfile"}, + "ssh_profile": {"key": "sshProfile", "type": "SshProfile"}, + "autoscale_profile": {"key": "autoscaleProfile", "type": "AutoscaleProfile"}, + "kafka_profile": {"key": "kafkaProfile", "type": "{object}"}, + "trino_profile": {"key": "trinoProfile", "type": "TrinoProfile"}, + "llap_profile": {"key": "llapProfile", "type": "{object}"}, + "flink_profile": {"key": "flinkProfile", "type": "FlinkProfile"}, + "spark_profile": {"key": "sparkProfile", "type": "SparkProfile"}, + "stub_profile": {"key": "stubProfile", "type": "{object}"}, + "script_action_profiles": {"key": "scriptActionProfiles", "type": "[ScriptActionProfile]"}, + } + + def __init__( + self, + *, + cluster_version: str, + oss_version: str, + identity_profile: "_models.IdentityProfile", + authorization_profile: "_models.AuthorizationProfile", + secrets_profile: Optional["_models.SecretsProfile"] = None, + service_configs_profiles: Optional[List["_models.ClusterServiceConfigsProfile"]] = None, + log_analytics_profile: Optional["_models.ClusterLogAnalyticsProfile"] = None, + prometheus_profile: Optional["_models.ClusterPrometheusProfile"] = None, + ssh_profile: Optional["_models.SshProfile"] = None, + autoscale_profile: Optional["_models.AutoscaleProfile"] = None, + kafka_profile: Optional[Dict[str, Any]] = None, + trino_profile: Optional["_models.TrinoProfile"] = None, + llap_profile: Optional[Dict[str, Any]] = None, + flink_profile: Optional["_models.FlinkProfile"] = None, + spark_profile: Optional["_models.SparkProfile"] = None, + stub_profile: Optional[Dict[str, Any]] = None, + script_action_profiles: Optional[List["_models.ScriptActionProfile"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword cluster_version: Version with 3/4 part. Required. + :paramtype cluster_version: str + :keyword oss_version: Version with three part. Required. + :paramtype oss_version: str + :keyword identity_profile: Identity Profile with details of an MSI. Required. + :paramtype identity_profile: ~azure.mgmt.hdinsightonaks.models.IdentityProfile + :keyword authorization_profile: Authorization profile with details of AAD user Ids and group + Ids authorized for data plane access. Required. + :paramtype authorization_profile: ~azure.mgmt.hdinsightonaks.models.AuthorizationProfile + :keyword secrets_profile: The cluster secret profile. + :paramtype secrets_profile: ~azure.mgmt.hdinsightonaks.models.SecretsProfile + :keyword service_configs_profiles: The service configs profiles. + :paramtype service_configs_profiles: + list[~azure.mgmt.hdinsightonaks.models.ClusterServiceConfigsProfile] + :keyword log_analytics_profile: Cluster log analytics profile to enable or disable OMS agent + for cluster. + :paramtype log_analytics_profile: ~azure.mgmt.hdinsightonaks.models.ClusterLogAnalyticsProfile + :keyword prometheus_profile: Cluster Prometheus profile. + :paramtype prometheus_profile: ~azure.mgmt.hdinsightonaks.models.ClusterPrometheusProfile + :keyword ssh_profile: Ssh profile for the cluster. + :paramtype ssh_profile: ~azure.mgmt.hdinsightonaks.models.SshProfile + :keyword autoscale_profile: This is the Autoscale profile for the cluster. This will allow + customer to create cluster enabled with Autoscale. + :paramtype autoscale_profile: ~azure.mgmt.hdinsightonaks.models.AutoscaleProfile + :keyword kafka_profile: Kafka cluster profile. + :paramtype kafka_profile: dict[str, any] + :keyword trino_profile: Trino Cluster profile. + :paramtype trino_profile: ~azure.mgmt.hdinsightonaks.models.TrinoProfile + :keyword llap_profile: LLAP cluster profile. + :paramtype llap_profile: dict[str, any] + :keyword flink_profile: The Flink cluster profile. + :paramtype flink_profile: ~azure.mgmt.hdinsightonaks.models.FlinkProfile + :keyword spark_profile: The spark cluster profile. + :paramtype spark_profile: ~azure.mgmt.hdinsightonaks.models.SparkProfile + :keyword stub_profile: Stub cluster profile. + :paramtype stub_profile: dict[str, any] + :keyword script_action_profiles: The script action profile list. + :paramtype script_action_profiles: list[~azure.mgmt.hdinsightonaks.models.ScriptActionProfile] + """ + super().__init__(**kwargs) + self.cluster_version = cluster_version + self.oss_version = oss_version + self.components = None + self.identity_profile = identity_profile + self.authorization_profile = authorization_profile + self.secrets_profile = secrets_profile + self.service_configs_profiles = service_configs_profiles + self.connectivity_profile = None + self.log_analytics_profile = log_analytics_profile + self.prometheus_profile = prometheus_profile + self.ssh_profile = ssh_profile + self.autoscale_profile = autoscale_profile + self.kafka_profile = kafka_profile + self.trino_profile = trino_profile + self.llap_profile = llap_profile + self.flink_profile = flink_profile + self.spark_profile = spark_profile + self.stub_profile = stub_profile + self.script_action_profiles = script_action_profiles + + +class ClusterPrometheusProfile(_serialization.Model): + """Cluster Prometheus profile. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: Enable Prometheus for cluster or not. Required. + :vartype enabled: bool + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: bool = False, **kwargs: Any) -> None: + """ + :keyword enabled: Enable Prometheus for cluster or not. Required. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + + +class ClusterResizeData(TrackedResource): + """The parameters for resizing a cluster. + + 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. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar target_worker_node_count: Target node count of worker node. + :vartype target_worker_node_count: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "target_worker_node_count": {"key": "properties.targetWorkerNodeCount", "type": "int"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + target_worker_node_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword target_worker_node_count: Target node count of worker node. + :paramtype target_worker_node_count: int + """ + super().__init__(tags=tags, location=location, **kwargs) + self.target_worker_node_count = target_worker_node_count + + +class ClusterServiceConfig(_serialization.Model): + """Cluster configs per component. + + All required parameters must be populated in order to send to Azure. + + :ivar component: Name of the component the config files should apply to. Required. + :vartype component: str + :ivar files: List of Config Files. Required. + :vartype files: list[~azure.mgmt.hdinsightonaks.models.ClusterConfigFile] + """ + + _validation = { + "component": {"required": True}, + "files": {"required": True}, + } + + _attribute_map = { + "component": {"key": "component", "type": "str"}, + "files": {"key": "files", "type": "[ClusterConfigFile]"}, + } + + def __init__(self, *, component: str, files: List["_models.ClusterConfigFile"], **kwargs: Any) -> None: + """ + :keyword component: Name of the component the config files should apply to. Required. + :paramtype component: str + :keyword files: List of Config Files. Required. + :paramtype files: list[~azure.mgmt.hdinsightonaks.models.ClusterConfigFile] + """ + super().__init__(**kwargs) + self.component = component + self.files = files + + +class ClusterServiceConfigsProfile(_serialization.Model): + """Cluster service configs. + + All required parameters must be populated in order to send to Azure. + + :ivar service_name: Name of the service the configurations should apply to. Required. + :vartype service_name: str + :ivar configs: List of service configs. Required. + :vartype configs: list[~azure.mgmt.hdinsightonaks.models.ClusterServiceConfig] + """ + + _validation = { + "service_name": {"required": True}, + "configs": {"required": True}, + } + + _attribute_map = { + "service_name": {"key": "serviceName", "type": "str"}, + "configs": {"key": "configs", "type": "[ClusterServiceConfig]"}, + } + + def __init__(self, *, service_name: str, configs: List["_models.ClusterServiceConfig"], **kwargs: Any) -> None: + """ + :keyword service_name: Name of the service the configurations should apply to. Required. + :paramtype service_name: str + :keyword configs: List of service configs. Required. + :paramtype configs: list[~azure.mgmt.hdinsightonaks.models.ClusterServiceConfig] + """ + super().__init__(**kwargs) + self.service_name = service_name + self.configs = configs + + +class ClusterVersion(ProxyResource): + """Available cluster version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hdinsightonaks.models.SystemData + :ivar cluster_type: The type of cluster. + :vartype cluster_type: str + :ivar cluster_version: Version with three part. + :vartype cluster_version: str + :ivar oss_version: Version with three part. + :vartype oss_version: str + :ivar cluster_pool_version: The two part cluster pool version. If the cluster version is before + cluster pool version on-board, the return value will be empty string. + :vartype cluster_pool_version: str + :ivar is_preview: Indicate if this version is in preview or not. + :vartype is_preview: bool + :ivar components: Component list of this cluster type and version. + :vartype components: list[~azure.mgmt.hdinsightonaks.models.ClusterComponentsItem] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "cluster_type": {"pattern": r"^[a-zA-Z][a-zA-Z0-9]{0,31}$"}, + "cluster_version": {"pattern": r"^(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})$"}, + "oss_version": {"pattern": r"^(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})\.(0|[1-9][0-9]{0,18})$"}, + "components": {"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"}, + "cluster_type": {"key": "properties.clusterType", "type": "str"}, + "cluster_version": {"key": "properties.clusterVersion", "type": "str"}, + "oss_version": {"key": "properties.ossVersion", "type": "str"}, + "cluster_pool_version": {"key": "properties.clusterPoolVersion", "type": "str"}, + "is_preview": {"key": "properties.isPreview", "type": "bool"}, + "components": {"key": "properties.components", "type": "[ClusterComponentsItem]"}, + } + + def __init__( + self, + *, + cluster_type: Optional[str] = None, + cluster_version: Optional[str] = None, + oss_version: Optional[str] = None, + cluster_pool_version: Optional[str] = None, + is_preview: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword cluster_type: The type of cluster. + :paramtype cluster_type: str + :keyword cluster_version: Version with three part. + :paramtype cluster_version: str + :keyword oss_version: Version with three part. + :paramtype oss_version: str + :keyword cluster_pool_version: The two part cluster pool version. If the cluster version is + before cluster pool version on-board, the return value will be empty string. + :paramtype cluster_pool_version: str + :keyword is_preview: Indicate if this version is in preview or not. + :paramtype is_preview: bool + """ + super().__init__(**kwargs) + self.cluster_type = cluster_type + self.cluster_version = cluster_version + self.oss_version = oss_version + self.cluster_pool_version = cluster_pool_version + self.is_preview = is_preview + self.components = None + + +class ClusterVersionsListResult(_serialization.Model): + """Represents a list of cluster versions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of cluster versions. + :vartype value: list[~azure.mgmt.hdinsightonaks.models.ClusterVersion] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ClusterVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ClusterVersion"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of cluster versions. + :paramtype value: list[~azure.mgmt.hdinsightonaks.models.ClusterVersion] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ComparisonRule(_serialization.Model): + """The comparison rule. + + All required parameters must be populated in order to send to Azure. + + :ivar operator: The comparison operator. Required. Known values are: "greaterThan", + "greaterThanOrEqual", "lessThan", and "lessThanOrEqual". + :vartype operator: str or ~azure.mgmt.hdinsightonaks.models.ComparisonOperator + :ivar threshold: Threshold setting. Required. + :vartype threshold: float + """ + + _validation = { + "operator": {"required": True}, + "threshold": {"required": True}, + } + + _attribute_map = { + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + } + + def __init__(self, *, operator: Union[str, "_models.ComparisonOperator"], threshold: float, **kwargs: Any) -> None: + """ + :keyword operator: The comparison operator. Required. Known values are: "greaterThan", + "greaterThanOrEqual", "lessThan", and "lessThanOrEqual". + :paramtype operator: str or ~azure.mgmt.hdinsightonaks.models.ComparisonOperator + :keyword threshold: Threshold setting. Required. + :paramtype threshold: float + """ + super().__init__(**kwargs) + self.operator = operator + self.threshold = threshold + + +class ComputeProfile(_serialization.Model): + """The compute profile. + + All required parameters must be populated in order to send to Azure. + + :ivar nodes: The nodes definitions. Required. + :vartype nodes: list[~azure.mgmt.hdinsightonaks.models.NodeProfile] + """ + + _validation = { + "nodes": {"required": True}, + } + + _attribute_map = { + "nodes": {"key": "nodes", "type": "[NodeProfile]"}, + } + + def __init__(self, *, nodes: List["_models.NodeProfile"], **kwargs: Any) -> None: + """ + :keyword nodes: The nodes definitions. Required. + :paramtype nodes: list[~azure.mgmt.hdinsightonaks.models.NodeProfile] + """ + super().__init__(**kwargs) + self.nodes = nodes + + +class ComputeResourceDefinition(_serialization.Model): + """The cpu and memory requirement definition. + + All required parameters must be populated in order to send to Azure. + + :ivar cpu: The required CPU. Required. + :vartype cpu: float + :ivar memory: The required memory in MB, Container memory will be 110 percentile. Required. + :vartype memory: int + """ + + _validation = { + "cpu": {"required": True}, + "memory": {"required": True}, + } + + _attribute_map = { + "cpu": {"key": "cpu", "type": "float"}, + "memory": {"key": "memory", "type": "int"}, + } + + def __init__(self, *, cpu: float, memory: int, **kwargs: Any) -> None: + """ + :keyword cpu: The required CPU. Required. + :paramtype cpu: float + :keyword memory: The required memory in MB, Container memory will be 110 percentile. Required. + :paramtype memory: int + """ + super().__init__(**kwargs) + self.cpu = cpu + self.memory = memory + + +class ConnectivityProfile(_serialization.Model): + """Cluster connectivity profile. + + All required parameters must be populated in order to send to Azure. + + :ivar web: Web connectivity endpoint details. Required. + :vartype web: ~azure.mgmt.hdinsightonaks.models.ConnectivityProfileWeb + :ivar ssh: List of SSH connectivity endpoints. + :vartype ssh: list[~azure.mgmt.hdinsightonaks.models.SshConnectivityEndpoint] + """ + + _validation = { + "web": {"required": True}, + } + + _attribute_map = { + "web": {"key": "web", "type": "ConnectivityProfileWeb"}, + "ssh": {"key": "ssh", "type": "[SshConnectivityEndpoint]"}, + } + + def __init__( + self, + *, + web: "_models.ConnectivityProfileWeb", + ssh: Optional[List["_models.SshConnectivityEndpoint"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword web: Web connectivity endpoint details. Required. + :paramtype web: ~azure.mgmt.hdinsightonaks.models.ConnectivityProfileWeb + :keyword ssh: List of SSH connectivity endpoints. + :paramtype ssh: list[~azure.mgmt.hdinsightonaks.models.SshConnectivityEndpoint] + """ + super().__init__(**kwargs) + self.web = web + self.ssh = ssh + + +class WebConnectivityEndpoint(_serialization.Model): + """Web connectivity endpoint details. + + All required parameters must be populated in order to send to Azure. + + :ivar fqdn: Web connectivity endpoint. Required. + :vartype fqdn: str + """ + + _validation = { + "fqdn": {"required": True}, + } + + _attribute_map = { + "fqdn": {"key": "fqdn", "type": "str"}, + } + + def __init__(self, *, fqdn: str, **kwargs: Any) -> None: + """ + :keyword fqdn: Web connectivity endpoint. Required. + :paramtype fqdn: str + """ + super().__init__(**kwargs) + self.fqdn = fqdn + + +class ConnectivityProfileWeb(WebConnectivityEndpoint): + """Web connectivity endpoint details. + + All required parameters must be populated in order to send to Azure. + + :ivar fqdn: Web connectivity endpoint. Required. + :vartype fqdn: str + """ + + _validation = { + "fqdn": {"required": True}, + } + + _attribute_map = { + "fqdn": {"key": "fqdn", "type": "str"}, + } + + def __init__(self, *, fqdn: str, **kwargs: Any) -> None: + """ + :keyword fqdn: Web connectivity endpoint. Required. + :paramtype fqdn: str + """ + super().__init__(fqdn=fqdn, **kwargs) + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.hdinsightonaks.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.hdinsightonaks.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.hdinsightonaks.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.hdinsightonaks.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class FlinkCatalogOptions(_serialization.Model): + """Flink cluster catalog options. + + :ivar hive: Hive Catalog Option for Flink cluster. + :vartype hive: ~azure.mgmt.hdinsightonaks.models.FlinkHiveCatalogOption + """ + + _attribute_map = { + "hive": {"key": "hive", "type": "FlinkHiveCatalogOption"}, + } + + def __init__(self, *, hive: Optional["_models.FlinkHiveCatalogOption"] = None, **kwargs: Any) -> None: + """ + :keyword hive: Hive Catalog Option for Flink cluster. + :paramtype hive: ~azure.mgmt.hdinsightonaks.models.FlinkHiveCatalogOption + """ + super().__init__(**kwargs) + self.hive = hive + + +class FlinkHiveCatalogOption(_serialization.Model): + """Hive Catalog Option for Flink cluster. + + All required parameters must be populated in order to send to Azure. + + :ivar metastore_db_connection_password_secret: Secret reference name from + secretsProfile.secrets containing password for database connection. Required. + :vartype metastore_db_connection_password_secret: str + :ivar metastore_db_connection_url: Connection string for hive metastore database. Required. + :vartype metastore_db_connection_url: str + :ivar metastore_db_connection_user_name: User name for database connection. Required. + :vartype metastore_db_connection_user_name: str + """ + + _validation = { + "metastore_db_connection_password_secret": {"required": True}, + "metastore_db_connection_url": {"required": True}, + "metastore_db_connection_user_name": {"required": True}, + } + + _attribute_map = { + "metastore_db_connection_password_secret": {"key": "metastoreDbConnectionPasswordSecret", "type": "str"}, + "metastore_db_connection_url": {"key": "metastoreDbConnectionURL", "type": "str"}, + "metastore_db_connection_user_name": {"key": "metastoreDbConnectionUserName", "type": "str"}, + } + + def __init__( + self, + *, + metastore_db_connection_password_secret: str, + metastore_db_connection_url: str, + metastore_db_connection_user_name: str, + **kwargs: Any + ) -> None: + """ + :keyword metastore_db_connection_password_secret: Secret reference name from + secretsProfile.secrets containing password for database connection. Required. + :paramtype metastore_db_connection_password_secret: str + :keyword metastore_db_connection_url: Connection string for hive metastore database. Required. + :paramtype metastore_db_connection_url: str + :keyword metastore_db_connection_user_name: User name for database connection. Required. + :paramtype metastore_db_connection_user_name: str + """ + super().__init__(**kwargs) + self.metastore_db_connection_password_secret = metastore_db_connection_password_secret + self.metastore_db_connection_url = metastore_db_connection_url + self.metastore_db_connection_user_name = metastore_db_connection_user_name + + +class FlinkJobProperties(ClusterJobProperties): # pylint: disable=too-many-instance-attributes + """Properties of flink job. + + 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 job_type: Type of cluster job. Required. "FlinkJob" + :vartype job_type: str or ~azure.mgmt.hdinsightonaks.models.JobType + :ivar job_name: Name of job. Required. + :vartype job_name: str + :ivar job_jar_directory: A string property that specifies the directory where the job JAR is + located. + :vartype job_jar_directory: str + :ivar jar_name: A string property that represents the name of the job JAR. + :vartype jar_name: str + :ivar entry_class: A string property that specifies the entry class for the Flink job. + :vartype entry_class: str + :ivar args: A string property representing additional JVM arguments for the Flink job. It + should be space separated value. + :vartype args: str + :ivar save_point_name: A string property that represents the name of the savepoint for the + Flink job. + :vartype save_point_name: str + :ivar action: A string property that indicates the action to be performed on the Flink job. It + can have one of the following enum values => NEW, UPDATE, STATELESS_UPDATE, STOP, START, + CANCEL, SAVEPOINT, LIST_SAVEPOINT, or DELETE. Known values are: "NEW", "UPDATE", + "STATELESS_UPDATE", "STOP", "START", "CANCEL", "SAVEPOINT", "LIST_SAVEPOINT", and "DELETE". + :vartype action: str or ~azure.mgmt.hdinsightonaks.models.Action + :ivar flink_configuration: Additional properties used to configure Flink jobs. It allows users + to set properties such as parallelism and jobSavePointDirectory. It accepts additional + key-value pairs as properties, where the keys are strings and the values are strings as well. + :vartype flink_configuration: dict[str, str] + :ivar job_id: Unique id for identifying a job. + :vartype job_id: str + :ivar status: Status of job. + :vartype status: str + :ivar job_output: Output of job. + :vartype job_output: str + :ivar action_result: Action result of job. + :vartype action_result: str + :ivar last_save_point: The last savepoint. + :vartype last_save_point: str + """ + + _validation = { + "job_type": {"required": True}, + "job_name": {"required": True}, + "job_id": {"readonly": True}, + "status": {"readonly": True}, + "job_output": {"readonly": True}, + "action_result": {"readonly": True}, + "last_save_point": {"readonly": True}, + } + + _attribute_map = { + "job_type": {"key": "jobType", "type": "str"}, + "job_name": {"key": "jobName", "type": "str"}, + "job_jar_directory": {"key": "jobJarDirectory", "type": "str"}, + "jar_name": {"key": "jarName", "type": "str"}, + "entry_class": {"key": "entryClass", "type": "str"}, + "args": {"key": "args", "type": "str"}, + "save_point_name": {"key": "savePointName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "flink_configuration": {"key": "flinkConfiguration", "type": "{str}"}, + "job_id": {"key": "jobId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "job_output": {"key": "jobOutput", "type": "str"}, + "action_result": {"key": "actionResult", "type": "str"}, + "last_save_point": {"key": "lastSavePoint", "type": "str"}, + } + + def __init__( + self, + *, + job_name: str, + job_jar_directory: Optional[str] = None, + jar_name: Optional[str] = None, + entry_class: Optional[str] = None, + args: Optional[str] = None, + save_point_name: Optional[str] = None, + action: Optional[Union[str, "_models.Action"]] = None, + flink_configuration: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword job_name: Name of job. Required. + :paramtype job_name: str + :keyword job_jar_directory: A string property that specifies the directory where the job JAR is + located. + :paramtype job_jar_directory: str + :keyword jar_name: A string property that represents the name of the job JAR. + :paramtype jar_name: str + :keyword entry_class: A string property that specifies the entry class for the Flink job. + :paramtype entry_class: str + :keyword args: A string property representing additional JVM arguments for the Flink job. It + should be space separated value. + :paramtype args: str + :keyword save_point_name: A string property that represents the name of the savepoint for the + Flink job. + :paramtype save_point_name: str + :keyword action: A string property that indicates the action to be performed on the Flink job. + It can have one of the following enum values => NEW, UPDATE, STATELESS_UPDATE, STOP, START, + CANCEL, SAVEPOINT, LIST_SAVEPOINT, or DELETE. Known values are: "NEW", "UPDATE", + "STATELESS_UPDATE", "STOP", "START", "CANCEL", "SAVEPOINT", "LIST_SAVEPOINT", and "DELETE". + :paramtype action: str or ~azure.mgmt.hdinsightonaks.models.Action + :keyword flink_configuration: Additional properties used to configure Flink jobs. It allows + users to set properties such as parallelism and jobSavePointDirectory. It accepts additional + key-value pairs as properties, where the keys are strings and the values are strings as well. + :paramtype flink_configuration: dict[str, str] + """ + super().__init__(**kwargs) + self.job_type: str = "FlinkJob" + self.job_name = job_name + self.job_jar_directory = job_jar_directory + self.jar_name = jar_name + self.entry_class = entry_class + self.args = args + self.save_point_name = save_point_name + self.action = action + self.flink_configuration = flink_configuration + self.job_id = None + self.status = None + self.job_output = None + self.action_result = None + self.last_save_point = None + + +class FlinkProfile(_serialization.Model): + """The Flink cluster profile. + + All required parameters must be populated in order to send to Azure. + + :ivar storage: The storage profile. Required. + :vartype storage: ~azure.mgmt.hdinsightonaks.models.FlinkStorageProfile + :ivar num_replicas: The number of task managers. + :vartype num_replicas: int + :ivar job_manager: Job Manager container/ process CPU and memory requirements. Required. + :vartype job_manager: ~azure.mgmt.hdinsightonaks.models.ComputeResourceDefinition + :ivar history_server: History Server container/ process CPU and memory requirements. + :vartype history_server: ~azure.mgmt.hdinsightonaks.models.ComputeResourceDefinition + :ivar task_manager: Task Manager container/ process CPU and memory requirements. Required. + :vartype task_manager: ~azure.mgmt.hdinsightonaks.models.ComputeResourceDefinition + :ivar catalog_options: Flink cluster catalog options. + :vartype catalog_options: ~azure.mgmt.hdinsightonaks.models.FlinkCatalogOptions + """ + + _validation = { + "storage": {"required": True}, + "job_manager": {"required": True}, + "task_manager": {"required": True}, + } + + _attribute_map = { + "storage": {"key": "storage", "type": "FlinkStorageProfile"}, + "num_replicas": {"key": "numReplicas", "type": "int"}, + "job_manager": {"key": "jobManager", "type": "ComputeResourceDefinition"}, + "history_server": {"key": "historyServer", "type": "ComputeResourceDefinition"}, + "task_manager": {"key": "taskManager", "type": "ComputeResourceDefinition"}, + "catalog_options": {"key": "catalogOptions", "type": "FlinkCatalogOptions"}, + } + + def __init__( + self, + *, + storage: "_models.FlinkStorageProfile", + job_manager: "_models.ComputeResourceDefinition", + task_manager: "_models.ComputeResourceDefinition", + num_replicas: Optional[int] = None, + history_server: Optional["_models.ComputeResourceDefinition"] = None, + catalog_options: Optional["_models.FlinkCatalogOptions"] = None, + **kwargs: Any + ) -> None: + """ + :keyword storage: The storage profile. Required. + :paramtype storage: ~azure.mgmt.hdinsightonaks.models.FlinkStorageProfile + :keyword num_replicas: The number of task managers. + :paramtype num_replicas: int + :keyword job_manager: Job Manager container/ process CPU and memory requirements. Required. + :paramtype job_manager: ~azure.mgmt.hdinsightonaks.models.ComputeResourceDefinition + :keyword history_server: History Server container/ process CPU and memory requirements. + :paramtype history_server: ~azure.mgmt.hdinsightonaks.models.ComputeResourceDefinition + :keyword task_manager: Task Manager container/ process CPU and memory requirements. Required. + :paramtype task_manager: ~azure.mgmt.hdinsightonaks.models.ComputeResourceDefinition + :keyword catalog_options: Flink cluster catalog options. + :paramtype catalog_options: ~azure.mgmt.hdinsightonaks.models.FlinkCatalogOptions + """ + super().__init__(**kwargs) + self.storage = storage + self.num_replicas = num_replicas + self.job_manager = job_manager + self.history_server = history_server + self.task_manager = task_manager + self.catalog_options = catalog_options + + +class FlinkStorageProfile(_serialization.Model): + """The storage profile. + + All required parameters must be populated in order to send to Azure. + + :ivar storage_uri: Storage account uri which is used for savepoint and checkpoint state. + Required. + :vartype storage_uri: str + :ivar storagekey: Storage key is only required for wasb(s) storage. + :vartype storagekey: str + """ + + _validation = { + "storage_uri": {"required": True, "pattern": r"^(\w{4,5})://(.*)@(.*).\b(blob|dfs)\b\.core\.windows\.net$"}, + } + + _attribute_map = { + "storage_uri": {"key": "storageUri", "type": "str"}, + "storagekey": {"key": "storagekey", "type": "str"}, + } + + def __init__(self, *, storage_uri: str, storagekey: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword storage_uri: Storage account uri which is used for savepoint and checkpoint state. + Required. + :paramtype storage_uri: str + :keyword storagekey: Storage key is only required for wasb(s) storage. + :paramtype storagekey: str + """ + super().__init__(**kwargs) + self.storage_uri = storage_uri + self.storagekey = storagekey + + +class HiveCatalogOption(_serialization.Model): + """Hive Catalog Option. + + All required parameters must be populated in order to send to Azure. + + :ivar catalog_name: Name of trino catalog which should use specified hive metastore. Required. + :vartype catalog_name: str + :ivar metastore_db_connection_password_secret: Secret reference name from + secretsProfile.secrets containing password for database connection. Required. + :vartype metastore_db_connection_password_secret: str + :ivar metastore_db_connection_url: Connection string for hive metastore database. Required. + :vartype metastore_db_connection_url: str + :ivar metastore_db_connection_user_name: User name for database connection. Required. + :vartype metastore_db_connection_user_name: str + :ivar metastore_warehouse_dir: Metastore root directory URI, format: + abfs[s]://@:code:``.dfs.core.windows.net/:code:``. More details: + https://docs.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction-abfs-uri. + Required. + :vartype metastore_warehouse_dir: str + """ + + _validation = { + "catalog_name": {"required": True, "min_length": 1}, + "metastore_db_connection_password_secret": {"required": True}, + "metastore_db_connection_url": {"required": True}, + "metastore_db_connection_user_name": {"required": True}, + "metastore_warehouse_dir": {"required": True}, + } + + _attribute_map = { + "catalog_name": {"key": "catalogName", "type": "str"}, + "metastore_db_connection_password_secret": {"key": "metastoreDbConnectionPasswordSecret", "type": "str"}, + "metastore_db_connection_url": {"key": "metastoreDbConnectionURL", "type": "str"}, + "metastore_db_connection_user_name": {"key": "metastoreDbConnectionUserName", "type": "str"}, + "metastore_warehouse_dir": {"key": "metastoreWarehouseDir", "type": "str"}, + } + + def __init__( + self, + *, + catalog_name: str, + metastore_db_connection_password_secret: str, + metastore_db_connection_url: str, + metastore_db_connection_user_name: str, + metastore_warehouse_dir: str, + **kwargs: Any + ) -> None: + """ + :keyword catalog_name: Name of trino catalog which should use specified hive metastore. + Required. + :paramtype catalog_name: str + :keyword metastore_db_connection_password_secret: Secret reference name from + secretsProfile.secrets containing password for database connection. Required. + :paramtype metastore_db_connection_password_secret: str + :keyword metastore_db_connection_url: Connection string for hive metastore database. Required. + :paramtype metastore_db_connection_url: str + :keyword metastore_db_connection_user_name: User name for database connection. Required. + :paramtype metastore_db_connection_user_name: str + :keyword metastore_warehouse_dir: Metastore root directory URI, format: + abfs[s]://@:code:``.dfs.core.windows.net/:code:``. More details: + https://docs.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction-abfs-uri. + Required. + :paramtype metastore_warehouse_dir: str + """ + super().__init__(**kwargs) + self.catalog_name = catalog_name + self.metastore_db_connection_password_secret = metastore_db_connection_password_secret + self.metastore_db_connection_url = metastore_db_connection_url + self.metastore_db_connection_user_name = metastore_db_connection_user_name + self.metastore_warehouse_dir = metastore_warehouse_dir + + +class LoadBasedConfig(_serialization.Model): + """Profile of load based Autoscale. + + All required parameters must be populated in order to send to Azure. + + :ivar min_nodes: User needs to set the minimum number of nodes for load based scaling, the load + based scaling will use this to scale up and scale down between minimum and maximum number of + nodes. Required. + :vartype min_nodes: int + :ivar max_nodes: User needs to set the maximum number of nodes for load based scaling, the load + based scaling will use this to scale up and scale down between minimum and maximum number of + nodes. Required. + :vartype max_nodes: int + :ivar poll_interval: User can specify the poll interval, this is the time period (in seconds) + after which scaling metrics are polled for triggering a scaling operation. + :vartype poll_interval: int + :ivar cooldown_period: This is a cool down period, this is a time period in seconds, which + determines the amount of time that must elapse between a scaling activity started by a rule and + the start of the next scaling activity, regardless of the rule that triggers it. The default + value is 300 seconds. + :vartype cooldown_period: int + :ivar scaling_rules: The scaling rules. Required. + :vartype scaling_rules: list[~azure.mgmt.hdinsightonaks.models.ScalingRule] + """ + + _validation = { + "min_nodes": {"required": True}, + "max_nodes": {"required": True}, + "scaling_rules": {"required": True}, + } + + _attribute_map = { + "min_nodes": {"key": "minNodes", "type": "int"}, + "max_nodes": {"key": "maxNodes", "type": "int"}, + "poll_interval": {"key": "pollInterval", "type": "int"}, + "cooldown_period": {"key": "cooldownPeriod", "type": "int"}, + "scaling_rules": {"key": "scalingRules", "type": "[ScalingRule]"}, + } + + def __init__( + self, + *, + min_nodes: int, + max_nodes: int, + scaling_rules: List["_models.ScalingRule"], + poll_interval: Optional[int] = None, + cooldown_period: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword min_nodes: User needs to set the minimum number of nodes for load based scaling, the + load based scaling will use this to scale up and scale down between minimum and maximum number + of nodes. Required. + :paramtype min_nodes: int + :keyword max_nodes: User needs to set the maximum number of nodes for load based scaling, the + load based scaling will use this to scale up and scale down between minimum and maximum number + of nodes. Required. + :paramtype max_nodes: int + :keyword poll_interval: User can specify the poll interval, this is the time period (in + seconds) after which scaling metrics are polled for triggering a scaling operation. + :paramtype poll_interval: int + :keyword cooldown_period: This is a cool down period, this is a time period in seconds, which + determines the amount of time that must elapse between a scaling activity started by a rule and + the start of the next scaling activity, regardless of the rule that triggers it. The default + value is 300 seconds. + :paramtype cooldown_period: int + :keyword scaling_rules: The scaling rules. Required. + :paramtype scaling_rules: list[~azure.mgmt.hdinsightonaks.models.ScalingRule] + """ + super().__init__(**kwargs) + self.min_nodes = min_nodes + self.max_nodes = max_nodes + self.poll_interval = poll_interval + self.cooldown_period = cooldown_period + self.scaling_rules = scaling_rules + + +class NameAvailabilityParameters(_serialization.Model): + """Details of check name availability request body. + + :ivar name: Name for checking availability. + :vartype name: str + :ivar type: The resource type in Microsoft.HDInsight. + :vartype type: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Name for checking availability. + :paramtype name: str + :keyword type: The resource type in Microsoft.HDInsight. + :paramtype type: str + """ + super().__init__(**kwargs) + self.name = name + self.type = type + + +class NameAvailabilityResult(_serialization.Model): + """Result of check name availability. + + :ivar name_available: Indicator of availability of the Microsoft.HDInsight resource name. + :vartype name_available: bool + :ivar reason: The reason of unavailability. + :vartype reason: str + :ivar message: The error message of unavailability. + :vartype message: str + """ + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name_available: Indicator of availability of the Microsoft.HDInsight resource name. + :paramtype name_available: bool + :keyword reason: The reason of unavailability. + :paramtype reason: str + :keyword message: The error message of unavailability. + :paramtype message: str + """ + super().__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + +class NodeProfile(_serialization.Model): + """The node profile. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The node type. Required. + :vartype type: str + :ivar vm_size: The virtual machine SKU. Required. + :vartype vm_size: str + :ivar count: The number of virtual machines. Required. + :vartype count: int + """ + + _validation = { + "type": {"required": True, "pattern": r"^(head|Head|HEAD|worker|Worker|WORKER)$"}, + "vm_size": {"required": True, "pattern": r"^[a-zA-Z0-9_\-]{0,256}$"}, + "count": {"required": True, "minimum": 1}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "vm_size": {"key": "vmSize", "type": "str"}, + "count": {"key": "count", "type": "int"}, + } + + def __init__(self, *, type: str, vm_size: str, count: int, **kwargs: Any) -> None: + """ + :keyword type: The node type. Required. + :paramtype type: str + :keyword vm_size: The virtual machine SKU. Required. + :paramtype vm_size: str + :keyword count: The number of virtual machines. Required. + :paramtype count: int + """ + super().__init__(**kwargs) + self.type = type + self.vm_size = vm_size + self.count = count + + +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.hdinsightonaks.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.hdinsightonaks.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.hdinsightonaks.models.ActionType + """ + + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.hdinsightonaks.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(_serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(_serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.hdinsightonaks.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ScalingRule(_serialization.Model): + """The scaling rule. + + All required parameters must be populated in order to send to Azure. + + :ivar action_type: The action type. Required. Known values are: "scaleup" and "scaledown". + :vartype action_type: str or ~azure.mgmt.hdinsightonaks.models.ScaleActionType + :ivar evaluation_count: This is an evaluation count for a scaling condition, the number of + times a trigger condition should be successful, before scaling activity is triggered. Required. + :vartype evaluation_count: int + :ivar scaling_metric: Metrics name for individual workloads. For example: cpu. Required. + :vartype scaling_metric: str + :ivar comparison_rule: The comparison rule. Required. + :vartype comparison_rule: ~azure.mgmt.hdinsightonaks.models.ComparisonRule + """ + + _validation = { + "action_type": {"required": True}, + "evaluation_count": {"required": True}, + "scaling_metric": {"required": True}, + "comparison_rule": {"required": True}, + } + + _attribute_map = { + "action_type": {"key": "actionType", "type": "str"}, + "evaluation_count": {"key": "evaluationCount", "type": "int"}, + "scaling_metric": {"key": "scalingMetric", "type": "str"}, + "comparison_rule": {"key": "comparisonRule", "type": "ComparisonRule"}, + } + + def __init__( + self, + *, + action_type: Union[str, "_models.ScaleActionType"], + evaluation_count: int, + scaling_metric: str, + comparison_rule: "_models.ComparisonRule", + **kwargs: Any + ) -> None: + """ + :keyword action_type: The action type. Required. Known values are: "scaleup" and "scaledown". + :paramtype action_type: str or ~azure.mgmt.hdinsightonaks.models.ScaleActionType + :keyword evaluation_count: This is an evaluation count for a scaling condition, the number of + times a trigger condition should be successful, before scaling activity is triggered. Required. + :paramtype evaluation_count: int + :keyword scaling_metric: Metrics name for individual workloads. For example: cpu. Required. + :paramtype scaling_metric: str + :keyword comparison_rule: The comparison rule. Required. + :paramtype comparison_rule: ~azure.mgmt.hdinsightonaks.models.ComparisonRule + """ + super().__init__(**kwargs) + self.action_type = action_type + self.evaluation_count = evaluation_count + self.scaling_metric = scaling_metric + self.comparison_rule = comparison_rule + + +class Schedule(_serialization.Model): + """Schedule definition. + + All required parameters must be populated in order to send to Azure. + + :ivar start_time: User has to set the start time of current schedule configuration, format like + 10:30 (HH:MM). Required. + :vartype start_time: str + :ivar end_time: User has to set the end time of current schedule configuration, format like + 10:30 (HH:MM). Required. + :vartype end_time: str + :ivar count: User has to set the node count anticipated at end of the scaling operation of the + set current schedule configuration, format is integer. Required. + :vartype count: int + :ivar days: User has to set the days where schedule has to be set for autoscale operation. + Required. + :vartype days: list[str or ~azure.mgmt.hdinsightonaks.models.ScheduleDay] + """ + + _validation = { + "start_time": {"required": True, "pattern": r"^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$"}, + "end_time": {"required": True, "pattern": r"^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$"}, + "count": {"required": True}, + "days": {"required": True}, + } + + _attribute_map = { + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, + "count": {"key": "count", "type": "int"}, + "days": {"key": "days", "type": "[str]"}, + } + + def __init__( + self, + *, + start_time: str, + end_time: str, + count: int, + days: List[Union[str, "_models.ScheduleDay"]], + **kwargs: Any + ) -> None: + """ + :keyword start_time: User has to set the start time of current schedule configuration, format + like 10:30 (HH:MM). Required. + :paramtype start_time: str + :keyword end_time: User has to set the end time of current schedule configuration, format like + 10:30 (HH:MM). Required. + :paramtype end_time: str + :keyword count: User has to set the node count anticipated at end of the scaling operation of + the set current schedule configuration, format is integer. Required. + :paramtype count: int + :keyword days: User has to set the days where schedule has to be set for autoscale operation. + Required. + :paramtype days: list[str or ~azure.mgmt.hdinsightonaks.models.ScheduleDay] + """ + super().__init__(**kwargs) + self.start_time = start_time + self.end_time = end_time + self.count = count + self.days = days + + +class ScheduleBasedConfig(_serialization.Model): + """Profile of schedule based Autoscale. + + All required parameters must be populated in order to send to Azure. + + :ivar time_zone: User has to specify the timezone on which the schedule has to be set for + schedule based autoscale configuration. Required. + :vartype time_zone: str + :ivar default_count: Setting default node count of current schedule configuration. Default node + count specifies the number of nodes which are default when an specified scaling operation is + executed (scale up/scale down). Required. + :vartype default_count: int + :ivar schedules: This specifies the schedules where scheduled based Autoscale to be enabled, + the user has a choice to set multiple rules within the schedule across days and times + (start/end). Required. + :vartype schedules: list[~azure.mgmt.hdinsightonaks.models.Schedule] + """ + + _validation = { + "time_zone": {"required": True}, + "default_count": {"required": True}, + "schedules": {"required": True}, + } + + _attribute_map = { + "time_zone": {"key": "timeZone", "type": "str"}, + "default_count": {"key": "defaultCount", "type": "int"}, + "schedules": {"key": "schedules", "type": "[Schedule]"}, + } + + def __init__( + self, *, time_zone: str, default_count: int, schedules: List["_models.Schedule"], **kwargs: Any + ) -> None: + """ + :keyword time_zone: User has to specify the timezone on which the schedule has to be set for + schedule based autoscale configuration. Required. + :paramtype time_zone: str + :keyword default_count: Setting default node count of current schedule configuration. Default + node count specifies the number of nodes which are default when an specified scaling operation + is executed (scale up/scale down). Required. + :paramtype default_count: int + :keyword schedules: This specifies the schedules where scheduled based Autoscale to be enabled, + the user has a choice to set multiple rules within the schedule across days and times + (start/end). Required. + :paramtype schedules: list[~azure.mgmt.hdinsightonaks.models.Schedule] + """ + super().__init__(**kwargs) + self.time_zone = time_zone + self.default_count = default_count + self.schedules = schedules + + +class ScriptActionProfile(_serialization.Model): + """The script action profile. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of the script action. Supported type is bash scripts. Required. + :vartype type: str + :ivar name: Script name. Required. + :vartype name: str + :ivar url: Url of the script file. Required. + :vartype url: str + :ivar parameters: Additional parameters for the script action. It should be space-separated + list of arguments required for script execution. + :vartype parameters: str + :ivar services: List of services to apply the script action. Required. + :vartype services: list[str] + :ivar timeout_in_minutes: Timeout duration for the script action in minutes. + :vartype timeout_in_minutes: int + :ivar should_persist: Specify if the script should persist on the cluster. + :vartype should_persist: bool + """ + + _validation = { + "type": {"required": True}, + "name": {"required": True}, + "url": {"required": True, "pattern": r"^(https)|(http)|(abfss)|(abfs)|(wasbs)|(wasb)://.*$"}, + "services": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "parameters": {"key": "parameters", "type": "str"}, + "services": {"key": "services", "type": "[str]"}, + "timeout_in_minutes": {"key": "timeoutInMinutes", "type": "int"}, + "should_persist": {"key": "shouldPersist", "type": "bool"}, + } + + def __init__( + self, + *, + type: str, + name: str, + url: str, + services: List[str], + parameters: Optional[str] = None, + timeout_in_minutes: Optional[int] = None, + should_persist: bool = True, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of the script action. Supported type is bash scripts. Required. + :paramtype type: str + :keyword name: Script name. Required. + :paramtype name: str + :keyword url: Url of the script file. Required. + :paramtype url: str + :keyword parameters: Additional parameters for the script action. It should be space-separated + list of arguments required for script execution. + :paramtype parameters: str + :keyword services: List of services to apply the script action. Required. + :paramtype services: list[str] + :keyword timeout_in_minutes: Timeout duration for the script action in minutes. + :paramtype timeout_in_minutes: int + :keyword should_persist: Specify if the script should persist on the cluster. + :paramtype should_persist: bool + """ + super().__init__(**kwargs) + self.type = type + self.name = name + self.url = url + self.parameters = parameters + self.services = services + self.timeout_in_minutes = timeout_in_minutes + self.should_persist = should_persist + + +class SecretReference(_serialization.Model): + """Secret reference and corresponding properties of a key vault secret. + + All required parameters must be populated in order to send to Azure. + + :ivar reference_name: Reference name of the secret to be used in service configs. Required. + :vartype reference_name: str + :ivar type: Type of key vault object: secret, key or certificate. Required. Known values are: + "Key", "Secret", and "Certificate". + :vartype type: str or ~azure.mgmt.hdinsightonaks.models.KeyVaultObjectType + :ivar version: Version of the secret in key vault. + :vartype version: str + :ivar key_vault_object_name: Object identifier name of the secret in key vault. Required. + :vartype key_vault_object_name: str + """ + + _validation = { + "reference_name": {"required": True}, + "type": {"required": True}, + "key_vault_object_name": {"required": True, "pattern": r"^[a-zA-Z][a-zA-Z0-9-]{1,126}$"}, + } + + _attribute_map = { + "reference_name": {"key": "referenceName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "key_vault_object_name": {"key": "keyVaultObjectName", "type": "str"}, + } + + def __init__( + self, + *, + reference_name: str, + type: Union[str, "_models.KeyVaultObjectType"], + key_vault_object_name: str, + version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword reference_name: Reference name of the secret to be used in service configs. Required. + :paramtype reference_name: str + :keyword type: Type of key vault object: secret, key or certificate. Required. Known values + are: "Key", "Secret", and "Certificate". + :paramtype type: str or ~azure.mgmt.hdinsightonaks.models.KeyVaultObjectType + :keyword version: Version of the secret in key vault. + :paramtype version: str + :keyword key_vault_object_name: Object identifier name of the secret in key vault. Required. + :paramtype key_vault_object_name: str + """ + super().__init__(**kwargs) + self.reference_name = reference_name + self.type = type + self.version = version + self.key_vault_object_name = key_vault_object_name + + +class SecretsProfile(_serialization.Model): + """The cluster secret profile. + + All required parameters must be populated in order to send to Azure. + + :ivar key_vault_resource_id: Name of the user Key Vault where all the cluster specific user + secrets are stored. Required. + :vartype key_vault_resource_id: str + :ivar secrets: Properties of Key Vault secret. + :vartype secrets: list[~azure.mgmt.hdinsightonaks.models.SecretReference] + """ + + _validation = { + "key_vault_resource_id": {"required": True}, + } + + _attribute_map = { + "key_vault_resource_id": {"key": "keyVaultResourceId", "type": "str"}, + "secrets": {"key": "secrets", "type": "[SecretReference]"}, + } + + def __init__( + self, *, key_vault_resource_id: str, secrets: Optional[List["_models.SecretReference"]] = None, **kwargs: Any + ) -> None: + """ + :keyword key_vault_resource_id: Name of the user Key Vault where all the cluster specific user + secrets are stored. Required. + :paramtype key_vault_resource_id: str + :keyword secrets: Properties of Key Vault secret. + :paramtype secrets: list[~azure.mgmt.hdinsightonaks.models.SecretReference] + """ + super().__init__(**kwargs) + self.key_vault_resource_id = key_vault_resource_id + self.secrets = secrets + + +class ServiceConfigListResult(_serialization.Model): + """Cluster instance service configs api response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Cluster instance service config array. + :vartype value: list[~azure.mgmt.hdinsightonaks.models.ServiceConfigResult] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ServiceConfigResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ServiceConfigResult"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Cluster instance service config array. + :paramtype value: list[~azure.mgmt.hdinsightonaks.models.ServiceConfigResult] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ServiceConfigListResultProperties(_serialization.Model): + """Service config response. + + All required parameters must be populated in order to send to Azure. + + :ivar service_name: Service Config Name. Required. + :vartype service_name: str + :ivar file_name: File Name. Required. + :vartype file_name: str + :ivar content: Content in the service config file. + :vartype content: str + :ivar component_name: Component Name. Required. + :vartype component_name: str + :ivar type: Config type. + :vartype type: str + :ivar path: Config file path. + :vartype path: str + :ivar custom_keys: The custom keys. + :vartype custom_keys: dict[str, str] + :ivar default_keys: The default keys. + :vartype default_keys: dict[str, + ~azure.mgmt.hdinsightonaks.models.ServiceConfigListResultValueEntity] + """ + + _validation = { + "service_name": {"required": True}, + "file_name": {"required": True}, + "component_name": {"required": True}, + } + + _attribute_map = { + "service_name": {"key": "serviceName", "type": "str"}, + "file_name": {"key": "fileName", "type": "str"}, + "content": {"key": "content", "type": "str"}, + "component_name": {"key": "componentName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "custom_keys": {"key": "customKeys", "type": "{str}"}, + "default_keys": {"key": "defaultKeys", "type": "{ServiceConfigListResultValueEntity}"}, + } + + def __init__( + self, + *, + service_name: str, + file_name: str, + component_name: str, + content: Optional[str] = None, + type: Optional[str] = None, + path: Optional[str] = None, + custom_keys: Optional[Dict[str, str]] = None, + default_keys: Optional[Dict[str, "_models.ServiceConfigListResultValueEntity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_name: Service Config Name. Required. + :paramtype service_name: str + :keyword file_name: File Name. Required. + :paramtype file_name: str + :keyword content: Content in the service config file. + :paramtype content: str + :keyword component_name: Component Name. Required. + :paramtype component_name: str + :keyword type: Config type. + :paramtype type: str + :keyword path: Config file path. + :paramtype path: str + :keyword custom_keys: The custom keys. + :paramtype custom_keys: dict[str, str] + :keyword default_keys: The default keys. + :paramtype default_keys: dict[str, + ~azure.mgmt.hdinsightonaks.models.ServiceConfigListResultValueEntity] + """ + super().__init__(**kwargs) + self.service_name = service_name + self.file_name = file_name + self.content = content + self.component_name = component_name + self.type = type + self.path = path + self.custom_keys = custom_keys + self.default_keys = default_keys + + +class ServiceConfigListResultValueEntity(_serialization.Model): + """Default config details. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Config value. Required. + :vartype value: str + :ivar description: Config description. + :vartype description: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, *, value: str, description: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: Config value. Required. + :paramtype value: str + :keyword description: Config description. + :paramtype description: str + """ + super().__init__(**kwargs) + self.value = value + self.description = description + + +class ServiceConfigResult(_serialization.Model): + """Cluster instance service config. + + :ivar service_name: Service Config Name. + :vartype service_name: str + :ivar file_name: File Name. + :vartype file_name: str + :ivar content: Content in the service config file. + :vartype content: str + :ivar component_name: Component Name. + :vartype component_name: str + :ivar type: Config type. + :vartype type: str + :ivar path: Config file path. + :vartype path: str + :ivar custom_keys: The custom keys. + :vartype custom_keys: dict[str, str] + :ivar default_keys: The default keys. + :vartype default_keys: dict[str, + ~azure.mgmt.hdinsightonaks.models.ServiceConfigListResultValueEntity] + """ + + _attribute_map = { + "service_name": {"key": "properties.serviceName", "type": "str"}, + "file_name": {"key": "properties.fileName", "type": "str"}, + "content": {"key": "properties.content", "type": "str"}, + "component_name": {"key": "properties.componentName", "type": "str"}, + "type": {"key": "properties.type", "type": "str"}, + "path": {"key": "properties.path", "type": "str"}, + "custom_keys": {"key": "properties.customKeys", "type": "{str}"}, + "default_keys": {"key": "properties.defaultKeys", "type": "{ServiceConfigListResultValueEntity}"}, + } + + def __init__( + self, + *, + service_name: Optional[str] = None, + file_name: Optional[str] = None, + content: Optional[str] = None, + component_name: Optional[str] = None, + type: Optional[str] = None, + path: Optional[str] = None, + custom_keys: Optional[Dict[str, str]] = None, + default_keys: Optional[Dict[str, "_models.ServiceConfigListResultValueEntity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_name: Service Config Name. + :paramtype service_name: str + :keyword file_name: File Name. + :paramtype file_name: str + :keyword content: Content in the service config file. + :paramtype content: str + :keyword component_name: Component Name. + :paramtype component_name: str + :keyword type: Config type. + :paramtype type: str + :keyword path: Config file path. + :paramtype path: str + :keyword custom_keys: The custom keys. + :paramtype custom_keys: dict[str, str] + :keyword default_keys: The default keys. + :paramtype default_keys: dict[str, + ~azure.mgmt.hdinsightonaks.models.ServiceConfigListResultValueEntity] + """ + super().__init__(**kwargs) + self.service_name = service_name + self.file_name = file_name + self.content = content + self.component_name = component_name + self.type = type + self.path = path + self.custom_keys = custom_keys + self.default_keys = default_keys + + +class ServiceConfigResultProperties(ServiceConfigListResultProperties): + """Cluster instance service config properties. + + All required parameters must be populated in order to send to Azure. + + :ivar service_name: Service Config Name. Required. + :vartype service_name: str + :ivar file_name: File Name. Required. + :vartype file_name: str + :ivar content: Content in the service config file. + :vartype content: str + :ivar component_name: Component Name. Required. + :vartype component_name: str + :ivar type: Config type. + :vartype type: str + :ivar path: Config file path. + :vartype path: str + :ivar custom_keys: The custom keys. + :vartype custom_keys: dict[str, str] + :ivar default_keys: The default keys. + :vartype default_keys: dict[str, + ~azure.mgmt.hdinsightonaks.models.ServiceConfigListResultValueEntity] + """ + + _validation = { + "service_name": {"required": True}, + "file_name": {"required": True}, + "component_name": {"required": True}, + } + + _attribute_map = { + "service_name": {"key": "serviceName", "type": "str"}, + "file_name": {"key": "fileName", "type": "str"}, + "content": {"key": "content", "type": "str"}, + "component_name": {"key": "componentName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "custom_keys": {"key": "customKeys", "type": "{str}"}, + "default_keys": {"key": "defaultKeys", "type": "{ServiceConfigListResultValueEntity}"}, + } + + def __init__( + self, + *, + service_name: str, + file_name: str, + component_name: str, + content: Optional[str] = None, + type: Optional[str] = None, + path: Optional[str] = None, + custom_keys: Optional[Dict[str, str]] = None, + default_keys: Optional[Dict[str, "_models.ServiceConfigListResultValueEntity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_name: Service Config Name. Required. + :paramtype service_name: str + :keyword file_name: File Name. Required. + :paramtype file_name: str + :keyword content: Content in the service config file. + :paramtype content: str + :keyword component_name: Component Name. Required. + :paramtype component_name: str + :keyword type: Config type. + :paramtype type: str + :keyword path: Config file path. + :paramtype path: str + :keyword custom_keys: The custom keys. + :paramtype custom_keys: dict[str, str] + :keyword default_keys: The default keys. + :paramtype default_keys: dict[str, + ~azure.mgmt.hdinsightonaks.models.ServiceConfigListResultValueEntity] + """ + super().__init__( + service_name=service_name, + file_name=file_name, + content=content, + component_name=component_name, + type=type, + path=path, + custom_keys=custom_keys, + default_keys=default_keys, + **kwargs + ) + + +class ServiceStatus(_serialization.Model): + """Describes the status of a service of a HDInsight on aks cluster. + + All required parameters must be populated in order to send to Azure. + + :ivar kind: Kind of the service. E.g. "Zookeeper". Required. + :vartype kind: str + :ivar ready: Indicates if the service is ready / healthy. Values can be "true", "false", + "unknown" or anything else. Required. + :vartype ready: str + :ivar message: A message describing the error if any. + :vartype message: str + """ + + _validation = { + "kind": {"required": True}, + "ready": {"required": True}, + } + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + "ready": {"key": "ready", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, kind: str, ready: str, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword kind: Kind of the service. E.g. "Zookeeper". Required. + :paramtype kind: str + :keyword ready: Indicates if the service is ready / healthy. Values can be "true", "false", + "unknown" or anything else. Required. + :paramtype ready: str + :keyword message: A message describing the error if any. + :paramtype message: str + """ + super().__init__(**kwargs) + self.kind = kind + self.ready = ready + self.message = message + + +class SparkMetastoreSpec(_serialization.Model): + """The metastore specification for Spark cluster. + + All required parameters must be populated in order to send to Azure. + + :ivar db_server_host: The database server host. Required. + :vartype db_server_host: str + :ivar db_name: The database name. + :vartype db_name: str + :ivar db_user_name: The database user name. Required. + :vartype db_user_name: str + :ivar db_password_secret_name: The secret name which contains the database user password. + Required. + :vartype db_password_secret_name: str + :ivar key_vault_id: The key vault resource id. Required. + :vartype key_vault_id: str + :ivar thrift_url: The thrift url. + :vartype thrift_url: str + """ + + _validation = { + "db_server_host": {"required": True}, + "db_user_name": {"required": True}, + "db_password_secret_name": {"required": True}, + "key_vault_id": {"required": True}, + } + + _attribute_map = { + "db_server_host": {"key": "dbServerHost", "type": "str"}, + "db_name": {"key": "dbName", "type": "str"}, + "db_user_name": {"key": "dbUserName", "type": "str"}, + "db_password_secret_name": {"key": "dbPasswordSecretName", "type": "str"}, + "key_vault_id": {"key": "keyVaultId", "type": "str"}, + "thrift_url": {"key": "thriftUrl", "type": "str"}, + } + + def __init__( + self, + *, + db_server_host: str, + db_user_name: str, + db_password_secret_name: str, + key_vault_id: str, + db_name: Optional[str] = None, + thrift_url: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword db_server_host: The database server host. Required. + :paramtype db_server_host: str + :keyword db_name: The database name. + :paramtype db_name: str + :keyword db_user_name: The database user name. Required. + :paramtype db_user_name: str + :keyword db_password_secret_name: The secret name which contains the database user password. + Required. + :paramtype db_password_secret_name: str + :keyword key_vault_id: The key vault resource id. Required. + :paramtype key_vault_id: str + :keyword thrift_url: The thrift url. + :paramtype thrift_url: str + """ + super().__init__(**kwargs) + self.db_server_host = db_server_host + self.db_name = db_name + self.db_user_name = db_user_name + self.db_password_secret_name = db_password_secret_name + self.key_vault_id = key_vault_id + self.thrift_url = thrift_url + + +class SparkProfile(_serialization.Model): + """The spark cluster profile. + + :ivar default_storage_url: The default storage URL. + :vartype default_storage_url: str + :ivar metastore_spec: The metastore specification for Spark cluster. + :vartype metastore_spec: ~azure.mgmt.hdinsightonaks.models.SparkMetastoreSpec + :ivar user_plugins_spec: Spark user plugins spec. + :vartype user_plugins_spec: ~azure.mgmt.hdinsightonaks.models.SparkUserPlugins + """ + + _attribute_map = { + "default_storage_url": {"key": "defaultStorageUrl", "type": "str"}, + "metastore_spec": {"key": "metastoreSpec", "type": "SparkMetastoreSpec"}, + "user_plugins_spec": {"key": "userPluginsSpec", "type": "SparkUserPlugins"}, + } + + def __init__( + self, + *, + default_storage_url: Optional[str] = None, + metastore_spec: Optional["_models.SparkMetastoreSpec"] = None, + user_plugins_spec: Optional["_models.SparkUserPlugins"] = None, + **kwargs: Any + ) -> None: + """ + :keyword default_storage_url: The default storage URL. + :paramtype default_storage_url: str + :keyword metastore_spec: The metastore specification for Spark cluster. + :paramtype metastore_spec: ~azure.mgmt.hdinsightonaks.models.SparkMetastoreSpec + :keyword user_plugins_spec: Spark user plugins spec. + :paramtype user_plugins_spec: ~azure.mgmt.hdinsightonaks.models.SparkUserPlugins + """ + super().__init__(**kwargs) + self.default_storage_url = default_storage_url + self.metastore_spec = metastore_spec + self.user_plugins_spec = user_plugins_spec + + +class SparkUserPlugin(_serialization.Model): + """Spark user plugin. + + All required parameters must be populated in order to send to Azure. + + :ivar path: Fully qualified path to the folder containing the plugins. Required. + :vartype path: str + """ + + _validation = { + "path": {"required": True, "min_length": 1, "pattern": r"^(https)|(abfss)://.*$"}, + } + + _attribute_map = { + "path": {"key": "path", "type": "str"}, + } + + def __init__(self, *, path: str, **kwargs: Any) -> None: + """ + :keyword path: Fully qualified path to the folder containing the plugins. Required. + :paramtype path: str + """ + super().__init__(**kwargs) + self.path = path + + +class SparkUserPlugins(_serialization.Model): + """Spark user plugins spec. + + :ivar plugins: Spark user plugins. + :vartype plugins: list[~azure.mgmt.hdinsightonaks.models.SparkUserPlugin] + """ + + _attribute_map = { + "plugins": {"key": "plugins", "type": "[SparkUserPlugin]"}, + } + + def __init__(self, *, plugins: Optional[List["_models.SparkUserPlugin"]] = None, **kwargs: Any) -> None: + """ + :keyword plugins: Spark user plugins. + :paramtype plugins: list[~azure.mgmt.hdinsightonaks.models.SparkUserPlugin] + """ + super().__init__(**kwargs) + self.plugins = plugins + + +class SshConnectivityEndpoint(_serialization.Model): + """SSH connectivity endpoint details. + + All required parameters must be populated in order to send to Azure. + + :ivar endpoint: SSH connectivity endpoint. Required. + :vartype endpoint: str + """ + + _validation = { + "endpoint": {"required": True}, + } + + _attribute_map = { + "endpoint": {"key": "endpoint", "type": "str"}, + } + + def __init__(self, *, endpoint: str, **kwargs: Any) -> None: + """ + :keyword endpoint: SSH connectivity endpoint. Required. + :paramtype endpoint: str + """ + super().__init__(**kwargs) + self.endpoint = endpoint + + +class SshProfile(_serialization.Model): + """Ssh profile for the cluster. + + 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 count: Number of ssh pods per cluster. Required. + :vartype count: int + :ivar pod_prefix: Prefix of the pod names. Pod number will be appended to the prefix. The + ingress URLs for the pods will be available at + :code:``/:code:``/:code:``-:code:``. + :vartype pod_prefix: str + """ + + _validation = { + "count": {"required": True, "maximum": 5, "minimum": 0}, + "pod_prefix": {"readonly": True}, + } + + _attribute_map = { + "count": {"key": "count", "type": "int"}, + "pod_prefix": {"key": "podPrefix", "type": "str"}, + } + + def __init__(self, *, count: int, **kwargs: Any) -> None: + """ + :keyword count: Number of ssh pods per cluster. Required. + :paramtype count: int + """ + super().__init__(**kwargs) + self.count = count + self.pod_prefix = None + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.hdinsightonaks.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.hdinsightonaks.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :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.hdinsightonaks.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.hdinsightonaks.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 + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TagsObject(_serialization.Model): + """Tags object for patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class TrinoCoordinator(_serialization.Model): + """Trino Coordinator. + + :ivar high_availability_enabled: The flag that if enable coordinator HA, uses multiple + coordinator replicas with auto failover, one per each head node. Default: true. + :vartype high_availability_enabled: bool + :ivar enable: The flag that if enable debug or not. + :vartype enable: bool + :ivar port: The debug port. + :vartype port: int + :ivar suspend: The flag that if suspend debug or not. + :vartype suspend: bool + """ + + _attribute_map = { + "high_availability_enabled": {"key": "highAvailabilityEnabled", "type": "bool"}, + "enable": {"key": "debug.enable", "type": "bool"}, + "port": {"key": "debug.port", "type": "int"}, + "suspend": {"key": "debug.suspend", "type": "bool"}, + } + + def __init__( + self, + *, + high_availability_enabled: bool = True, + enable: bool = False, + port: int = 8008, + suspend: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword high_availability_enabled: The flag that if enable coordinator HA, uses multiple + coordinator replicas with auto failover, one per each head node. Default: true. + :paramtype high_availability_enabled: bool + :keyword enable: The flag that if enable debug or not. + :paramtype enable: bool + :keyword port: The debug port. + :paramtype port: int + :keyword suspend: The flag that if suspend debug or not. + :paramtype suspend: bool + """ + super().__init__(**kwargs) + self.high_availability_enabled = high_availability_enabled + self.enable = enable + self.port = port + self.suspend = suspend + + +class TrinoProfile(_serialization.Model): + """Trino Cluster profile. + + :ivar catalog_options: Trino cluster catalog options. + :vartype catalog_options: ~azure.mgmt.hdinsightonaks.models.CatalogOptions + :ivar coordinator: Trino Coordinator. + :vartype coordinator: ~azure.mgmt.hdinsightonaks.models.TrinoCoordinator + :ivar user_plugins_spec: Trino user plugins spec. + :vartype user_plugins_spec: ~azure.mgmt.hdinsightonaks.models.TrinoUserPlugins + :ivar user_telemetry_spec: User telemetry. + :vartype user_telemetry_spec: ~azure.mgmt.hdinsightonaks.models.TrinoUserTelemetry + :ivar worker: Trino worker. + :vartype worker: ~azure.mgmt.hdinsightonaks.models.TrinoWorker + """ + + _attribute_map = { + "catalog_options": {"key": "catalogOptions", "type": "CatalogOptions"}, + "coordinator": {"key": "coordinator", "type": "TrinoCoordinator"}, + "user_plugins_spec": {"key": "userPluginsSpec", "type": "TrinoUserPlugins"}, + "user_telemetry_spec": {"key": "userTelemetrySpec", "type": "TrinoUserTelemetry"}, + "worker": {"key": "worker", "type": "TrinoWorker"}, + } + + def __init__( + self, + *, + catalog_options: Optional["_models.CatalogOptions"] = None, + coordinator: Optional["_models.TrinoCoordinator"] = None, + user_plugins_spec: Optional["_models.TrinoUserPlugins"] = None, + user_telemetry_spec: Optional["_models.TrinoUserTelemetry"] = None, + worker: Optional["_models.TrinoWorker"] = None, + **kwargs: Any + ) -> None: + """ + :keyword catalog_options: Trino cluster catalog options. + :paramtype catalog_options: ~azure.mgmt.hdinsightonaks.models.CatalogOptions + :keyword coordinator: Trino Coordinator. + :paramtype coordinator: ~azure.mgmt.hdinsightonaks.models.TrinoCoordinator + :keyword user_plugins_spec: Trino user plugins spec. + :paramtype user_plugins_spec: ~azure.mgmt.hdinsightonaks.models.TrinoUserPlugins + :keyword user_telemetry_spec: User telemetry. + :paramtype user_telemetry_spec: ~azure.mgmt.hdinsightonaks.models.TrinoUserTelemetry + :keyword worker: Trino worker. + :paramtype worker: ~azure.mgmt.hdinsightonaks.models.TrinoWorker + """ + super().__init__(**kwargs) + self.catalog_options = catalog_options + self.coordinator = coordinator + self.user_plugins_spec = user_plugins_spec + self.user_telemetry_spec = user_telemetry_spec + self.worker = worker + + +class TrinoTelemetryConfig(_serialization.Model): + """Trino user telemetry definition. + + :ivar hivecatalog_name: Hive Catalog name used to mount external tables on the logs written by + trino, if not specified there tables are not created. + :vartype hivecatalog_name: str + :ivar hivecatalog_schema: Schema of the above catalog to use, to mount query logs as external + tables, if not specified tables will be mounted under schema trinologs. + :vartype hivecatalog_schema: str + :ivar partition_retention_in_days: Retention period for query log table partitions, this + doesn't have any affect on actual data. + :vartype partition_retention_in_days: int + :ivar path: Azure storage location of the blobs. + :vartype path: str + """ + + _validation = { + "hivecatalog_name": {"min_length": 1}, + "path": {"min_length": 1}, + } + + _attribute_map = { + "hivecatalog_name": {"key": "hivecatalogName", "type": "str"}, + "hivecatalog_schema": {"key": "hivecatalogSchema", "type": "str"}, + "partition_retention_in_days": {"key": "partitionRetentionInDays", "type": "int"}, + "path": {"key": "path", "type": "str"}, + } + + def __init__( + self, + *, + hivecatalog_name: Optional[str] = None, + hivecatalog_schema: str = "trinologs", + partition_retention_in_days: int = 365, + path: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword hivecatalog_name: Hive Catalog name used to mount external tables on the logs written + by trino, if not specified there tables are not created. + :paramtype hivecatalog_name: str + :keyword hivecatalog_schema: Schema of the above catalog to use, to mount query logs as + external tables, if not specified tables will be mounted under schema trinologs. + :paramtype hivecatalog_schema: str + :keyword partition_retention_in_days: Retention period for query log table partitions, this + doesn't have any affect on actual data. + :paramtype partition_retention_in_days: int + :keyword path: Azure storage location of the blobs. + :paramtype path: str + """ + super().__init__(**kwargs) + self.hivecatalog_name = hivecatalog_name + self.hivecatalog_schema = hivecatalog_schema + self.partition_retention_in_days = partition_retention_in_days + self.path = path + + +class TrinoUserPlugin(_serialization.Model): + """Trino user plugin. + + :ivar enabled: Denotes whether the plugin is active or not. + :vartype enabled: bool + :ivar name: This field maps to the sub-directory in trino plugins location, that will contain + all the plugins under path. + :vartype name: str + :ivar path: Fully qualified path to the folder containing the plugins. + :vartype path: str + """ + + _validation = { + "name": {"min_length": 1}, + "path": {"min_length": 1, "pattern": r"^(https)|(abfss)://.*$"}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "path": {"key": "path", "type": "str"}, + } + + def __init__( + self, *, enabled: Optional[bool] = None, name: Optional[str] = None, path: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword enabled: Denotes whether the plugin is active or not. + :paramtype enabled: bool + :keyword name: This field maps to the sub-directory in trino plugins location, that will + contain all the plugins under path. + :paramtype name: str + :keyword path: Fully qualified path to the folder containing the plugins. + :paramtype path: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.name = name + self.path = path + + +class TrinoUserPlugins(_serialization.Model): + """Trino user plugins spec. + + :ivar plugins: Trino user plugins. + :vartype plugins: list[~azure.mgmt.hdinsightonaks.models.TrinoUserPlugin] + """ + + _attribute_map = { + "plugins": {"key": "plugins", "type": "[TrinoUserPlugin]"}, + } + + def __init__(self, *, plugins: Optional[List["_models.TrinoUserPlugin"]] = None, **kwargs: Any) -> None: + """ + :keyword plugins: Trino user plugins. + :paramtype plugins: list[~azure.mgmt.hdinsightonaks.models.TrinoUserPlugin] + """ + super().__init__(**kwargs) + self.plugins = plugins + + +class TrinoUserTelemetry(_serialization.Model): + """User telemetry. + + :ivar storage: Trino user telemetry definition. + :vartype storage: ~azure.mgmt.hdinsightonaks.models.TrinoTelemetryConfig + """ + + _attribute_map = { + "storage": {"key": "storage", "type": "TrinoTelemetryConfig"}, + } + + def __init__(self, *, storage: Optional["_models.TrinoTelemetryConfig"] = None, **kwargs: Any) -> None: + """ + :keyword storage: Trino user telemetry definition. + :paramtype storage: ~azure.mgmt.hdinsightonaks.models.TrinoTelemetryConfig + """ + super().__init__(**kwargs) + self.storage = storage + + +class TrinoWorker(_serialization.Model): + """Trino worker. + + :ivar enable: The flag that if enable debug or not. + :vartype enable: bool + :ivar port: The debug port. + :vartype port: int + :ivar suspend: The flag that if suspend debug or not. + :vartype suspend: bool + """ + + _attribute_map = { + "enable": {"key": "debug.enable", "type": "bool"}, + "port": {"key": "debug.port", "type": "int"}, + "suspend": {"key": "debug.suspend", "type": "bool"}, + } + + def __init__(self, *, enable: bool = False, port: int = 8008, suspend: bool = False, **kwargs: Any) -> None: + """ + :keyword enable: The flag that if enable debug or not. + :paramtype enable: bool + :keyword port: The debug port. + :paramtype port: int + :keyword suspend: The flag that if suspend debug or not. + :paramtype suspend: bool + """ + super().__init__(**kwargs) + self.enable = enable + self.port = port + self.suspend = suspend + + +class UpdatableClusterProfile(_serialization.Model): + """Cluster resource patch properties. + + :ivar service_configs_profiles: The service configs profiles. + :vartype service_configs_profiles: + list[~azure.mgmt.hdinsightonaks.models.ClusterServiceConfigsProfile] + :ivar ssh_profile: Ssh profile for the cluster. + :vartype ssh_profile: ~azure.mgmt.hdinsightonaks.models.SshProfile + :ivar autoscale_profile: This is the Autoscale profile for the cluster. This will allow + customer to create cluster enabled with Autoscale. + :vartype autoscale_profile: ~azure.mgmt.hdinsightonaks.models.AutoscaleProfile + :ivar authorization_profile: Authorization profile with details of AAD user Ids and group Ids + authorized for data plane access. + :vartype authorization_profile: ~azure.mgmt.hdinsightonaks.models.AuthorizationProfile + :ivar log_analytics_profile: Cluster log analytics profile to enable or disable OMS agent for + cluster. + :vartype log_analytics_profile: ~azure.mgmt.hdinsightonaks.models.ClusterLogAnalyticsProfile + :ivar prometheus_profile: Cluster Prometheus profile. + :vartype prometheus_profile: ~azure.mgmt.hdinsightonaks.models.ClusterPrometheusProfile + :ivar script_action_profiles: The script action profile list. + :vartype script_action_profiles: list[~azure.mgmt.hdinsightonaks.models.ScriptActionProfile] + """ + + _attribute_map = { + "service_configs_profiles": {"key": "serviceConfigsProfiles", "type": "[ClusterServiceConfigsProfile]"}, + "ssh_profile": {"key": "sshProfile", "type": "SshProfile"}, + "autoscale_profile": {"key": "autoscaleProfile", "type": "AutoscaleProfile"}, + "authorization_profile": {"key": "authorizationProfile", "type": "AuthorizationProfile"}, + "log_analytics_profile": {"key": "logAnalyticsProfile", "type": "ClusterLogAnalyticsProfile"}, + "prometheus_profile": {"key": "prometheusProfile", "type": "ClusterPrometheusProfile"}, + "script_action_profiles": {"key": "scriptActionProfiles", "type": "[ScriptActionProfile]"}, + } + + def __init__( + self, + *, + service_configs_profiles: Optional[List["_models.ClusterServiceConfigsProfile"]] = None, + ssh_profile: Optional["_models.SshProfile"] = None, + autoscale_profile: Optional["_models.AutoscaleProfile"] = None, + authorization_profile: Optional["_models.AuthorizationProfile"] = None, + log_analytics_profile: Optional["_models.ClusterLogAnalyticsProfile"] = None, + prometheus_profile: Optional["_models.ClusterPrometheusProfile"] = None, + script_action_profiles: Optional[List["_models.ScriptActionProfile"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_configs_profiles: The service configs profiles. + :paramtype service_configs_profiles: + list[~azure.mgmt.hdinsightonaks.models.ClusterServiceConfigsProfile] + :keyword ssh_profile: Ssh profile for the cluster. + :paramtype ssh_profile: ~azure.mgmt.hdinsightonaks.models.SshProfile + :keyword autoscale_profile: This is the Autoscale profile for the cluster. This will allow + customer to create cluster enabled with Autoscale. + :paramtype autoscale_profile: ~azure.mgmt.hdinsightonaks.models.AutoscaleProfile + :keyword authorization_profile: Authorization profile with details of AAD user Ids and group + Ids authorized for data plane access. + :paramtype authorization_profile: ~azure.mgmt.hdinsightonaks.models.AuthorizationProfile + :keyword log_analytics_profile: Cluster log analytics profile to enable or disable OMS agent + for cluster. + :paramtype log_analytics_profile: ~azure.mgmt.hdinsightonaks.models.ClusterLogAnalyticsProfile + :keyword prometheus_profile: Cluster Prometheus profile. + :paramtype prometheus_profile: ~azure.mgmt.hdinsightonaks.models.ClusterPrometheusProfile + :keyword script_action_profiles: The script action profile list. + :paramtype script_action_profiles: list[~azure.mgmt.hdinsightonaks.models.ScriptActionProfile] + """ + super().__init__(**kwargs) + self.service_configs_profiles = service_configs_profiles + self.ssh_profile = ssh_profile + self.autoscale_profile = autoscale_profile + self.authorization_profile = authorization_profile + self.log_analytics_profile = log_analytics_profile + self.prometheus_profile = prometheus_profile + self.script_action_profiles = script_action_profiles diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/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/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/__init__.py new file mode 100644 index 000000000000..3c44ccd0cd62 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/__init__.py @@ -0,0 +1,31 @@ +# 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 ._cluster_pools_operations import ClusterPoolsOperations +from ._clusters_operations import ClustersOperations +from ._cluster_jobs_operations import ClusterJobsOperations +from ._locations_operations import LocationsOperations +from ._operations import Operations +from ._available_cluster_pool_versions_operations import AvailableClusterPoolVersionsOperations +from ._available_cluster_versions_operations import AvailableClusterVersionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ClusterPoolsOperations", + "ClustersOperations", + "ClusterJobsOperations", + "LocationsOperations", + "Operations", + "AvailableClusterPoolVersionsOperations", + "AvailableClusterVersionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_available_cluster_pool_versions_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_available_cluster_pool_versions_operations.py new file mode 100644 index 000000000000..dd6cc2032df7 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_available_cluster_pool_versions_operations.py @@ -0,0 +1,170 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_location_request(location: 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/availableClusterPoolVersions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AvailableClusterPoolVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.HDInsightOnAksMgmtClient`'s + :attr:`available_cluster_pool_versions` 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 list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.ClusterPoolVersion"]: + """Returns a list of available cluster pool versions. + + :param location: The name of the Azure region. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterPoolVersion or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterPoolVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterPoolVersionsListResult] = kwargs.pop("cls", None) + + 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_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterPoolVersionsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_location.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/availableClusterPoolVersions" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_available_cluster_versions_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_available_cluster_versions_operations.py new file mode 100644 index 000000000000..0323f42f9fc7 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_available_cluster_versions_operations.py @@ -0,0 +1,170 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_location_request(location: 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/availableClusterVersions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AvailableClusterVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.HDInsightOnAksMgmtClient`'s + :attr:`available_cluster_versions` 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 list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.ClusterVersion"]: + """Returns a list of available cluster versions. + + :param location: The name of the Azure region. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterVersion or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterVersionsListResult] = kwargs.pop("cls", None) + + 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_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterVersionsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_location.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/availableClusterVersions" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_cluster_jobs_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_cluster_jobs_operations.py new file mode 100644 index 000000000000..a539f2bacf43 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_cluster_jobs_operations.py @@ -0,0 +1,463 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_run_job_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/runJob", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +def build_list_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/jobs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ClusterJobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.HDInsightOnAksMgmtClient`'s + :attr:`cluster_jobs` 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") + + def _run_job_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_job: Union[_models.ClusterJob, IO], + **kwargs: Any + ) -> Optional[_models.ClusterJob]: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ClusterJob]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_job, (IOBase, bytes)): + _content = cluster_job + else: + _json = self._serialize.body(cluster_job, "ClusterJob") + + request = build_run_job_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._run_job_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ClusterJob", pipeline_response) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _run_job_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/runJob" + } + + @overload + def begin_run_job( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_job: _models.ClusterJob, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterJob]: + """Operations on jobs of HDInsight on AKS cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_job: The Cluster job. Required. + :type cluster_job: ~azure.mgmt.hdinsightonaks.models.ClusterJob + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterJob or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_run_job( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_job: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterJob]: + """Operations on jobs of HDInsight on AKS cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_job: The Cluster job. Required. + :type cluster_job: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterJob or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_run_job( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_job: Union[_models.ClusterJob, IO], + **kwargs: Any + ) -> LROPoller[_models.ClusterJob]: + """Operations on jobs of HDInsight on AKS cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_job: The Cluster job. Is either a ClusterJob type or a IO type. Required. + :type cluster_job: ~azure.mgmt.hdinsightonaks.models.ClusterJob 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterJob or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterJob] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._run_job_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + cluster_job=cluster_job, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterJob", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_run_job.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/runJob" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ClusterJob"]: + """Get jobs of HDInsight on AKS cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterJob or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterJob] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterJobList] = kwargs.pop("cls", None) + + 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, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterJobList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/jobs" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_cluster_pools_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_cluster_pools_operations.py new file mode 100644 index 000000000000..e76cb0e82f28 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_cluster_pools_operations.py @@ -0,0 +1,1059 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_tags_request( + resource_group_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_delete_request( + resource_group_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusterpools") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ClusterPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.HDInsightOnAksMgmtClient`'s + :attr:`cluster_pools` 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, cluster_pool_name: str, **kwargs: Any) -> _models.ClusterPool: + """Gets a cluster pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClusterPool or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.ClusterPool + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool: Union[_models.ClusterPool, IO], + **kwargs: Any + ) -> _models.ClusterPool: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_pool, (IOBase, bytes)): + _content = cluster_pool + else: + _json = self._serialize.body(cluster_pool, "ClusterPool") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_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_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool: _models.ClusterPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterPool]: + """Creates or updates a cluster pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool: The Cluster Pool to create. Required. + :type cluster_pool: ~azure.mgmt.hdinsightonaks.models.ClusterPool + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterPool]: + """Creates or updates a cluster pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool: The Cluster Pool to create. Required. + :type cluster_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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool: Union[_models.ClusterPool, IO], + **kwargs: Any + ) -> LROPoller[_models.ClusterPool]: + """Creates or updates a cluster pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool: The Cluster Pool to create. Is either a ClusterPool type or a IO type. + Required. + :type cluster_pool: ~azure.mgmt.hdinsightonaks.models.ClusterPool 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_pool=cluster_pool, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterPool", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + def _update_tags_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool_tags: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ClusterPool: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_pool_tags, (IOBase, bytes)): + _content = cluster_pool_tags + else: + _json = self._serialize.body(cluster_pool_tags, "TagsObject") + + request = build_update_tags_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_tags_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("ClusterPool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_tags_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + @overload + def begin_update_tags( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool_tags: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterPool]: + """Updates an existing Cluster Pool Tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool_tags: Parameters supplied to update tags. Required. + :type cluster_pool_tags: ~azure.mgmt.hdinsightonaks.models.TagsObject + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_tags( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterPool]: + """Updates an existing Cluster Pool Tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool_tags: Parameters supplied to update tags. Required. + :type cluster_pool_tags: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_tags( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_pool_tags: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> LROPoller[_models.ClusterPool]: + """Updates an existing Cluster Pool Tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_pool_tags: Parameters supplied to update tags. Is either a TagsObject type or a + IO type. Required. + :type cluster_pool_tags: ~azure.mgmt.hdinsightonaks.models.TagsObject 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPool or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClusterPool] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_tags_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_pool_tags=cluster_pool_tags, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterPool", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_pool_name: str, **kwargs: Any + ) -> None: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, cluster_pool_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Cluster Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}" + } + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ClusterPool"]: + """Gets the list of Cluster Pools within a Subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterPool or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterPoolListResult] = kwargs.pop("cls", None) + + 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_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) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterPoolListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusterpools" + } + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ClusterPool"]: + """Lists the HDInsight cluster pools under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterPool or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterPoolListResult] = kwargs.pop("cls", None) + + 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterPoolListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_clusters_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_clusters_operations.py new file mode 100644 index 000000000000..e74483e1d2c1 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_clusters_operations.py @@ -0,0 +1,1633 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_cluster_pool_name_request( + resource_group_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_resize_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/resize", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +def build_get_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_delete_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_list_service_configs_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/serviceConfigs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_instance_views_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/instanceViews", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_instance_view_request( + resource_group_name: str, cluster_pool_name: str, cluster_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/instanceViews/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterPoolName": _SERIALIZER.url("cluster_pool_name", cluster_pool_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.HDInsightOnAksMgmtClient`'s + :attr:`clusters` 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 list_by_cluster_pool_name( + self, resource_group_name: str, cluster_pool_name: str, **kwargs: Any + ) -> Iterable["_models.Cluster"]: + """Lists the HDInsight cluster pools under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_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 Cluster or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) + + 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_by_cluster_pool_name_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster_pool_name.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_cluster_pool_name.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters" + } + + def _resize_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_resize_request: Union[_models.ClusterResizeData, IO], + **kwargs: Any + ) -> Optional[_models.Cluster]: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Cluster]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_resize_request, (IOBase, bytes)): + _content = cluster_resize_request + else: + _json = self._serialize.body(cluster_resize_request, "ClusterResizeData") + + request = build_resize_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._resize_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Cluster", pipeline_response) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _resize_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/resize" + } + + @overload + def begin_resize( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_resize_request: _models.ClusterResizeData, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Resize an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_resize_request: Resize a cluster. Required. + :type cluster_resize_request: ~azure.mgmt.hdinsightonaks.models.ClusterResizeData + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_resize( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_resize_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Resize an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_resize_request: Resize a cluster. Required. + :type cluster_resize_request: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_resize( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_resize_request: Union[_models.ClusterResizeData, IO], + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Resize an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_resize_request: Resize a cluster. Is either a ClusterResizeData type or a IO + type. Required. + :type cluster_resize_request: ~azure.mgmt.hdinsightonaks.models.ClusterResizeData 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._resize_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + cluster_resize_request=cluster_resize_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Cluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_resize.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/resize" + } + + @distributed_trace + def get( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> _models.Cluster: + """Gets a HDInsight cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.Cluster + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Cluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + def _create_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + hd_insight_cluster: Union[_models.Cluster, IO], + **kwargs: Any + ) -> _models.Cluster: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(hd_insight_cluster, (IOBase, bytes)): + _content = hd_insight_cluster + else: + _json = self._serialize.body(hd_insight_cluster, "Cluster") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Cluster", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Cluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + hd_insight_cluster: _models.Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Creates a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param hd_insight_cluster: The cluster to create. Required. + :type hd_insight_cluster: ~azure.mgmt.hdinsightonaks.models.Cluster + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + hd_insight_cluster: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Creates a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param hd_insight_cluster: The cluster to create. Required. + :type hd_insight_cluster: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + hd_insight_cluster: Union[_models.Cluster, IO], + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Creates a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param hd_insight_cluster: The cluster to create. Is either a Cluster type or a IO type. + Required. + :type hd_insight_cluster: ~azure.mgmt.hdinsightonaks.models.Cluster 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + hd_insight_cluster=hd_insight_cluster, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Cluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + def _update_initial( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_patch_request: Union[_models.ClusterPatch, IO], + **kwargs: Any + ) -> _models.Cluster: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_patch_request, (IOBase, bytes)): + _content = cluster_patch_request + else: + _json = self._serialize.body(cluster_patch_request, "ClusterPatch") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Cluster", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Cluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_patch_request: _models.ClusterPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Updates an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_patch_request: Patch a cluster. Required. + :type cluster_patch_request: ~azure.mgmt.hdinsightonaks.models.ClusterPatch + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_patch_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Updates an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_patch_request: Patch a cluster. Required. + :type cluster_patch_request: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_pool_name: str, + cluster_name: str, + cluster_patch_request: Union[_models.ClusterPatch, IO], + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Updates an existing Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :param cluster_patch_request: Patch a cluster. Is either a ClusterPatch type or a IO type. + Required. + :type cluster_patch_request: ~azure.mgmt.hdinsightonaks.models.ClusterPatch 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsightonaks.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + cluster_patch_request=cluster_patch_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Cluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> None: + 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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}" + } + + @distributed_trace + def list_service_configs( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ServiceConfigResult"]: + """Lists the config dump of all services running in cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServiceConfigResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.ServiceConfigResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServiceConfigListResult] = kwargs.pop("cls", None) + + 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_service_configs_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_service_configs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServiceConfigListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_service_configs.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/serviceConfigs" + } + + @distributed_trace + def list_instance_views( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ClusterInstanceViewResult"]: + """Lists the lists of instance views. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClusterInstanceViewResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterInstanceViewsResult] = kwargs.pop("cls", None) + + 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_instance_views_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_instance_views.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterInstanceViewsResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_instance_views.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/instanceViews" + } + + @distributed_trace + def get_instance_view( + self, resource_group_name: str, cluster_pool_name: str, cluster_name: str, **kwargs: Any + ) -> _models.ClusterInstanceViewResult: + """Gets the status of a cluster instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_pool_name: The name of the cluster pool. Required. + :type cluster_pool_name: str + :param cluster_name: The name of the HDInsight cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClusterInstanceViewResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.ClusterInstanceViewResult + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterInstanceViewResult] = kwargs.pop("cls", None) + + request = build_get_instance_view_request( + resource_group_name=resource_group_name, + cluster_pool_name=cluster_pool_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_instance_view.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ClusterInstanceViewResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_instance_view.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusterpools/{clusterPoolName}/clusters/{clusterName}/instanceViews/default" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_locations_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_locations_operations.py new file mode 100644 index 000000000000..cf8718359603 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_locations_operations.py @@ -0,0 +1,210 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_check_name_availability_request(location: 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.HDInsightOnAksMgmtClient`'s + :attr:`locations` 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") + + @overload + def check_name_availability( + self, + location: str, + name_availability_parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityResult: + """Check the availability of the resource name. + + :param location: The name of the Azure region. Required. + :type location: str + :param name_availability_parameters: The name and type of the resource. Required. + :type name_availability_parameters: + ~azure.mgmt.hdinsightonaks.models.NameAvailabilityParameters + :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: NameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.NameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, name_availability_parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityResult: + """Check the availability of the resource name. + + :param location: The name of the Azure region. Required. + :type location: str + :param name_availability_parameters: The name and type of the resource. Required. + :type name_availability_parameters: 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: NameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.NameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, name_availability_parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailabilityResult: + """Check the availability of the resource name. + + :param location: The name of the Azure region. Required. + :type location: str + :param name_availability_parameters: The name and type of the resource. Is either a + NameAvailabilityParameters type or a IO type. Required. + :type name_availability_parameters: + ~azure.mgmt.hdinsightonaks.models.NameAvailabilityParameters 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: NameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsightonaks.models.NameAvailabilityResult + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(name_availability_parameters, (IOBase, bytes)): + _content = name_availability_parameters + else: + _json = self._serialize.body(name_availability_parameters, "NameAvailabilityParameters") + + request = build_check_name_availability_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/checkNameAvailability" + } diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_operations.py new file mode 100644 index 000000000000..28d3debe02b4 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_operations.py @@ -0,0 +1,155 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.HDInsight/operations") + + # 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 Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsightonaks.HDInsightOnAksMgmtClient`'s + :attr:`operations` 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Returns list of operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsightonaks.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + 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( + 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) + + 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) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.HDInsight/operations"} diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/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/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/py.typed b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/azure/mgmt/hdinsightonaks/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_autoscale_cluster.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_autoscale_cluster.py new file mode 100644 index 000000000000..1c0f29e74b31 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_autoscale_cluster.py @@ -0,0 +1,94 @@ +# 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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python create_autoscale_cluster.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.begin_create( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + cluster_name="cluster1", + hd_insight_cluster={ + "location": "West US 2", + "properties": { + "clusterProfile": { + "authorizationProfile": {"userIds": ["testuser1", "testuser2"]}, + "autoscaleProfile": { + "autoscaleType": "ScheduleBased", + "enabled": True, + "gracefulDecommissionTimeout": 3600, + "loadBasedConfig": { + "cooldownPeriod": 300, + "maxNodes": 20, + "minNodes": 10, + "pollInterval": 60, + "scalingRules": [ + { + "actionType": "scaleup", + "comparisonRule": {"operator": "greaterThan", "threshold": 90}, + "evaluationCount": 3, + "scalingMetric": "cpu", + }, + { + "actionType": "scaledown", + "comparisonRule": {"operator": "lessThan", "threshold": 20}, + "evaluationCount": 3, + "scalingMetric": "cpu", + }, + ], + }, + "scheduleBasedConfig": { + "defaultCount": 10, + "schedules": [ + {"count": 20, "days": ["Monday"], "endTime": "12:00", "startTime": "00:00"}, + {"count": 25, "days": ["Sunday"], "endTime": "12:00", "startTime": "00:00"}, + ], + "timeZone": "Cen. Australia Standard Time", + }, + }, + "clusterVersion": "1.0.1", + "identityProfile": { + "msiClientId": "de91f1d8-767f-460a-ac11-3cf103f74b34", + "msiObjectId": "40491351-c240-4042-91e0-f644a1d2b441", + "msiResourceId": "/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi", + }, + "kafkaProfile": {}, + "ossVersion": "2.4.1", + "sshProfile": {"count": 2}, + }, + "clusterType": "kafka", + "computeProfile": {"nodes": [{"count": 4, "type": "worker", "vmSize": "Standard_D3_v2"}]}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/CreateAutoscaleCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_cluster_pool.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_cluster_pool.py new file mode 100644 index 000000000000..c7e153f0caa5 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_cluster_pool.py @@ -0,0 +1,48 @@ +# 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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python create_cluster_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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.cluster_pools.begin_create_or_update( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + cluster_pool={ + "location": "West US 2", + "properties": { + "clusterPoolProfile": {"clusterPoolVersion": "1.2"}, + "computeProfile": {"count": 3, "vmSize": "Standard_D3_v2"}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/CreateClusterPool.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_spark_cluster.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_spark_cluster.py new file mode 100644 index 000000000000..aa5308f3f4d2 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/create_spark_cluster.py @@ -0,0 +1,98 @@ +# 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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python create_spark_cluster.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.begin_create( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + cluster_name="cluster1", + hd_insight_cluster={ + "location": "West US 2", + "properties": { + "clusterProfile": { + "authorizationProfile": {"userIds": ["testuser1", "testuser2"]}, + "clusterVersion": "0.0.1", + "identityProfile": { + "msiClientId": "de91f1d8-767f-460a-ac11-3cf103f74b34", + "msiObjectId": "40491351-c240-4042-91e0-f644a1d2b441", + "msiResourceId": "/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi", + }, + "ossVersion": "2.2.3", + "serviceConfigsProfiles": [ + { + "configs": [ + { + "component": "spark-config", + "files": [ + { + "fileName": "spark-defaults.conf", + "values": {"spark.eventLog.enabled": "true"}, + } + ], + } + ], + "serviceName": "spark-service", + }, + { + "configs": [ + { + "component": "yarn-config", + "files": [ + { + "fileName": "core-site.xml", + "values": { + "fs.defaultFS": "wasb://testcontainer@teststorage.dfs.core.windows.net/", + "storage.container": "testcontainer", + "storage.key": "test key", + "storage.name": "teststorage", + "storage.protocol": "wasb", + }, + }, + {"fileName": "yarn-site.xml", "values": {"yarn.webapp.ui2.enable": "false"}}, + ], + } + ], + "serviceName": "yarn-service", + }, + ], + "sparkProfile": {}, + "sshProfile": {"count": 2}, + }, + "clusterType": "spark", + "computeProfile": {"nodes": [{"count": 4, "type": "worker", "vmSize": "Standard_D3_v2"}]}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/CreateSparkCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/delete_cluster.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/delete_cluster.py new file mode 100644 index 000000000000..cc63a787060a --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/delete_cluster.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python delete_cluster.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + client.clusters.begin_delete( + resource_group_name="rg1", + cluster_pool_name="clusterpool1", + cluster_name="cluster1", + ).result() + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/DeleteCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/delete_cluster_pool.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/delete_cluster_pool.py new file mode 100644 index 000000000000..8dbd57a50716 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/delete_cluster_pool.py @@ -0,0 +1,40 @@ +# 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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python delete_cluster_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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + client.cluster_pools.begin_delete( + resource_group_name="rg1", + cluster_pool_name="clusterpool1", + ).result() + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/DeleteClusterPool.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster.py new file mode 100644 index 000000000000..4df8b7691a39 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python get_cluster.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.get( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + cluster_name="cluster1", + ) + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/GetCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster_instance_view.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster_instance_view.py new file mode 100644 index 000000000000..106ab9b8b20e --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster_instance_view.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python get_cluster_instance_view.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.get_instance_view( + resource_group_name="rg1", + cluster_pool_name="clusterPool1", + cluster_name="cluster1", + ) + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/GetClusterInstanceView.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster_pool.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster_pool.py new file mode 100644 index 000000000000..d18283f0e6fe --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_cluster_pool.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python get_cluster_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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.cluster_pools.get( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + ) + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/GetClusterPool.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_operations.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_operations.py new file mode 100644 index 000000000000..0e3d62567665 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/get_operations.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python get_operations.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/GetOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_available_cluster_pool_versions.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_available_cluster_pool_versions.py new file mode 100644 index 000000000000..27355ab92d7b --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_available_cluster_pool_versions.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python list_available_cluster_pool_versions.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.available_cluster_pool_versions.list_by_location( + location="westus2", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ListAvailableClusterPoolVersions.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_available_cluster_versions.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_available_cluster_versions.py new file mode 100644 index 000000000000..9e209b7ae53e --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_available_cluster_versions.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python list_available_cluster_versions.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.available_cluster_versions.list_by_location( + location="westus2", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ListAvailableClusterVersions.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_instance_views.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_instance_views.py new file mode 100644 index 000000000000..d9be8c1e35d5 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_instance_views.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python list_cluster_instance_views.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.list_instance_views( + resource_group_name="rg1", + cluster_pool_name="clusterPool1", + cluster_name="cluster1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ListClusterInstanceViews.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_jobs.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_jobs.py new file mode 100644 index 000000000000..b369822c4fe7 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_jobs.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python list_cluster_jobs.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.cluster_jobs.list( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterPool1", + cluster_name="cluster1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ListClusterJobs.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_pools.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_pools.py new file mode 100644 index 000000000000..cfd3e18a42dc --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_pools.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python list_cluster_pools.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.cluster_pools.list_by_resource_group( + resource_group_name="hiloResourcegroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ListClusterPools.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_pools_subscription.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_pools_subscription.py new file mode 100644 index 000000000000..a7ccd62295c2 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_pools_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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python list_cluster_pools_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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.cluster_pools.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ListClusterPoolsSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_service_configs.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_service_configs.py new file mode 100644 index 000000000000..924052c63927 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_cluster_service_configs.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python list_cluster_service_configs.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.list_service_configs( + resource_group_name="rg1", + cluster_pool_name="clusterPool1", + cluster_name="cluster1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ListClusterServiceConfigs.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_clusters_by_cluster_pool_name.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_clusters_by_cluster_pool_name.py new file mode 100644 index 000000000000..184850835067 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/list_clusters_by_cluster_pool_name.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python list_clusters_by_cluster_pool_name.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.list_by_cluster_pool_name( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ListClustersByClusterPoolName.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/locations_name_availability.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/locations_name_availability.py new file mode 100644 index 000000000000..0381031d6813 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/locations_name_availability.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python locations_name_availability.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.locations.check_name_availability( + location="southeastasia", + name_availability_parameters={"name": "contosemember1", "type": "Microsoft.HDInsight/clusterPools/clusters"}, + ) + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/LocationsNameAvailability.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/patch_cluster.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/patch_cluster.py new file mode 100644 index 000000000000..404f9af7f87b --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/patch_cluster.py @@ -0,0 +1,113 @@ +# 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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python patch_cluster.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.begin_update( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + cluster_name="cluster1", + cluster_patch_request={ + "location": "West US 2", + "properties": { + "clusterProfile": { + "authorizationProfile": {"userIds": ["Testuser1", "Testuser2"]}, + "autoscaleProfile": { + "autoscaleType": "ScheduleBased", + "enabled": True, + "gracefulDecommissionTimeout": -1, + "scheduleBasedConfig": { + "defaultCount": 3, + "schedules": [ + { + "count": 3, + "days": ["Monday, Tuesday, Wednesday"], + "endTime": "12:00", + "startTime": "00:00", + }, + {"count": 3, "days": ["Sunday"], "endTime": "12:00", "startTime": "00:00"}, + ], + "timeZone": "Cen. Australia Standard Time", + }, + }, + "logAnalyticsProfile": { + "applicationLogs": {"stdErrorEnabled": True, "stdOutEnabled": True}, + "enabled": True, + "metricsEnabled": True, + }, + "serviceConfigsProfiles": [ + { + "configs": [ + { + "component": "TestComp1", + "files": [ + { + "fileName": "TestFile1", + "values": {"Test.config.1": "1", "Test.config.2": "2"}, + }, + { + "fileName": "TestFile2", + "values": {"Test.config.3": "3", "Test.config.4": "4"}, + }, + ], + }, + { + "component": "TestComp2", + "files": [ + {"content": "TestContent", "fileName": "TestFile3", "path": "TestPath"}, + { + "fileName": "TestFile4", + "values": {"Test.config.7": "7", "Test.config.8": "8"}, + }, + ], + }, + ], + "serviceName": "TestService1", + }, + { + "configs": [ + { + "component": "TestComp3", + "files": [{"fileName": "TestFile5", "values": {"Test.config.9": "9"}}], + } + ], + "serviceName": "TestService2", + }, + ], + "sshProfile": {"count": 2}, + } + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/PatchCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/patch_cluster_pool.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/patch_cluster_pool.py new file mode 100644 index 000000000000..e7c47726ff25 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/patch_cluster_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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python patch_cluster_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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.cluster_pools.begin_update_tags( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + cluster_pool_tags={"tags": {"tag1": "value1", "tag2": "value2"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/PatchClusterPool.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/resize_cluster.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/resize_cluster.py new file mode 100644 index 000000000000..e57e7ae29ed5 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/resize_cluster.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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python resize_cluster.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.clusters.begin_resize( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + cluster_name="cluster1", + cluster_resize_request={"location": "West US 2", "properties": {"targetWorkerNodeCount": 5}}, + ).result() + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/ResizeCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/run_cluster_job.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/run_cluster_job.py new file mode 100644 index 000000000000..6ec977291700 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/generated_samples/run_cluster_job.py @@ -0,0 +1,56 @@ +# 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.hdinsightonaks import HDInsightOnAksMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hdinsightonaks +# USAGE + python run_cluster_job.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 = HDInsightOnAksMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="10e32bab-26da-4cc4-a441-52b318f824e6", + ) + + response = client.cluster_jobs.begin_run_job( + resource_group_name="hiloResourcegroup", + cluster_pool_name="clusterpool1", + cluster_name="cluster1", + cluster_job={ + "properties": { + "action": "START", + "entryClass": "com.microsoft.hilo.flink.job.streaming.SleepJob", + "flinkConfiguration": { + "parallelism": "1", + "savepoint.directory": "abfs://flinkjob@hilosa.dfs.core.windows.net/savepoint", + }, + "jarName": "flink-sleep-job-0.0.1-SNAPSHOT.jar", + "jobJarDirectory": "abfs://flinkjob@hilosa.dfs.core.windows.net/jars", + "jobName": "flink-job-name", + "jobType": "FlinkJob", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2023-06-01-preview/examples/RunClusterJob.json +if __name__ == "__main__": + main() diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/sdk_packaging.toml b/sdk/hdinsight/azure-mgmt-hdinsightonaks/sdk_packaging.toml new file mode 100644 index 000000000000..009776839f16 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/sdk_packaging.toml @@ -0,0 +1,11 @@ +[packaging] +package_name = "azure-mgmt-hdinsightonaks" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +sample_link = "" +exclude_folders = "" diff --git a/sdk/hdinsight/azure-mgmt-hdinsightonaks/setup.py b/sdk/hdinsight/azure-mgmt-hdinsightonaks/setup.py new file mode 100644 index 000000000000..40d8f82d0a73 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsightonaks/setup.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-hdinsightonaks" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace("-", ".") + +# Version extraction inspired from 'requests' +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + +with open("README.md", encoding="utf-8") as f: + readme = f.read() +with open("CHANGELOG.md", encoding="utf-8") as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), + include_package_data=True, + package_data={ + "pytyped": ["py.typed"], + }, + install_requires=[ + "isodate<1.0.0,>=0.6.1", + "azure-common~=1.1", + "azure-mgmt-core>=1.3.2,<2.0.0", + "typing-extensions>=4.3.0; python_version<'3.8.0'", + ], + python_requires=">=3.7", +) diff --git a/sdk/hdinsight/ci.yml b/sdk/hdinsight/ci.yml index 1962a45dfaaf..8cfd2a310cee 100644 --- a/sdk/hdinsight/ci.yml +++ b/sdk/hdinsight/ci.yml @@ -30,3 +30,5 @@ extends: Artifacts: - name: azure-mgmt-hdinsight safeName: azuremgmthdinsight + - name: azure-mgmt-hdinsightonaks + safeName: azuremgmthdinsightonaks