diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/CHANGELOG.md b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/CHANGELOG.md index c846f41c86ad..5f82ef91d400 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/CHANGELOG.md +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/CHANGELOG.md @@ -1,5 +1,35 @@ # Release History +## 1.0.0b1 (2020-12-09) + +This is beta preview version. + +This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming). + +**General breaking changes** + +- Credential system has been completly revamped: + + - `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported, use the `azure-identity` classes instead: https://pypi.org/project/azure-identity/ + - `credentials` parameter has been renamed `credential` + +- The `config` attribute no longer exists on a client, configuration should be passed as kwarg. Example: `MyClient(credential, subscription_id, enable_logging=True)`. For a complete set of + supported options, see the [parameters accept in init documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) +- You can't import a `version` module anymore, use `__version__` instead +- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`. +- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed). +- Most of the operation kwarg have changed. Some of the most noticeable: + + - `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user + - For a complete set of + supported options, see the [parameters accept in Request documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) + +**General new features** + +- Type annotations support using `typing`. SDKs are mypy ready. +- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client. +- This client now support natively tracing library like OpenCensus or OpenTelemetry. See this [tracing quickstart](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core-tracing-opentelemetry) for an overview. + ## 0.1.0 (2020-05-18) * Initial Release diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/README.md b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/README.md index b8b533f4ba3c..bb68f7493e8b 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/README.md +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/README.md @@ -4,6 +4,19 @@ This is the Microsoft Azure HybridKubernetes Management Client Library. This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). +# Usage + + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [Kubernetes Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + # Provide Feedback If you encounter any bugs or have suggestions, please file an issue in the diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/__init__.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/__init__.py index 3b6da4db90f0..580fd6adae41 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/__init__.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/__init__.py @@ -1,19 +1,19 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ConnectedKubernetesClientConfiguration from ._connected_kubernetes_client import ConnectedKubernetesClient -__all__ = ['ConnectedKubernetesClient', 'ConnectedKubernetesClientConfiguration'] - -from .version import VERSION +from ._version import VERSION __version__ = VERSION +__all__ = ['ConnectedKubernetesClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_configuration.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_configuration.py index 8e030344f5b3..1d51f3a1bdde 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_configuration.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_configuration.py @@ -1,48 +1,71 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class ConnectedKubernetesClientConfiguration(Configuration): + """Configuration for ConnectedKubernetesClient. -class ConnectedKubernetesClientConfiguration(AzureConfiguration): - """Configuration for ConnectedKubernetesClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' - - super(ConnectedKubernetesClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + super(ConnectedKubernetesClientConfiguration, self).__init__(**kwargs) - self.add_user_agent('azure-mgmt-hybridkubernetes/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2020-01-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-hybridkubernetes/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_connected_kubernetes_client.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_connected_kubernetes_client.py index 886bab977087..2902a78c0d4f 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_connected_kubernetes_client.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_connected_kubernetes_client.py @@ -1,16 +1,21 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential from ._configuration import ConnectedKubernetesClientConfiguration from .operations import ConnectedClusterOperations @@ -18,37 +23,53 @@ from . import models -class ConnectedKubernetesClient(SDKClient): - """Azure Connected Cluster Resource Provider API for adopting any Kubernetes Cluster +class ConnectedKubernetesClient(object): + """Azure Connected Cluster Resource Provider API for adopting any Kubernetes Cluster. - :ivar config: Configuration for client. - :vartype config: ConnectedKubernetesClientConfiguration - - :ivar connected_cluster: ConnectedCluster operations + :ivar connected_cluster: ConnectedClusterOperations operations :vartype connected_cluster: azure.mgmt.hybridkubernetes.operations.ConnectedClusterOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.hybridkubernetes.operations.Operations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ConnectedKubernetesClientConfiguration(credentials, subscription_id, base_url) - super(ConnectedKubernetesClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ConnectedKubernetesClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2020-01-01-preview' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.connected_cluster = ConnectedClusterOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ConnectedKubernetesClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/version.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_version.py similarity index 84% rename from sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/version.py rename to sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_version.py index e0ec669828cb..515f51c112dd 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/version.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/_version.py @@ -1,13 +1,10 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "0.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/__init__.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/__init__.py new file mode 100644 index 000000000000..a48d905f3b5f --- /dev/null +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._connected_kubernetes_client import ConnectedKubernetesClient +__all__ = ['ConnectedKubernetesClient'] diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/_configuration.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/_configuration.py new file mode 100644 index 000000000000..b86c11133e1c --- /dev/null +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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 + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ConnectedKubernetesClientConfiguration(Configuration): + """Configuration for ConnectedKubernetesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(ConnectedKubernetesClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-01-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-hybridkubernetes/{}'.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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/_connected_kubernetes_client.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/_connected_kubernetes_client.py new file mode 100644 index 000000000000..dbeb301cbdb0 --- /dev/null +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/_connected_kubernetes_client.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import ConnectedKubernetesClientConfiguration +from .operations import ConnectedClusterOperations +from .operations import Operations +from .. import models + + +class ConnectedKubernetesClient(object): + """Azure Connected Cluster Resource Provider API for adopting any Kubernetes Cluster. + + :ivar connected_cluster: ConnectedClusterOperations operations + :vartype connected_cluster: azure.mgmt.hybridkubernetes.aio.operations.ConnectedClusterOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.hybridkubernetes.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = ConnectedKubernetesClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.connected_cluster = ConnectedClusterOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ConnectedKubernetesClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/__init__.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/__init__.py new file mode 100644 index 000000000000..4bf80ae81ea0 --- /dev/null +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._connected_cluster_operations import ConnectedClusterOperations +from ._operations import Operations + +__all__ = [ + 'ConnectedClusterOperations', + 'Operations', +] diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/_connected_cluster_operations.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/_connected_cluster_operations.py new file mode 100644 index 000000000000..a7c3b8946182 --- /dev/null +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/_connected_cluster_operations.py @@ -0,0 +1,639 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConnectedClusterOperations: + """ConnectedClusterOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.hybridkubernetes.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_initial( + self, + resource_group_name: str, + cluster_name: str, + connected_cluster: "_models.ConnectedCluster", + **kwargs + ) -> "_models.ConnectedCluster": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedCluster"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(connected_cluster, 'ConnectedCluster') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ConnectedCluster', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConnectedCluster', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore + + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + connected_cluster: "_models.ConnectedCluster", + **kwargs + ) -> AsyncLROPoller["_models.ConnectedCluster"]: + """Register a new Kubernetes cluster with Azure Resource Manager. + + API to register a new Kubernetes cluster and create a tracked resource in Azure Resource + Manager (ARM). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_name: The name of the Kubernetes cluster on which get is called. + :type cluster_name: str + :param connected_cluster: Parameters supplied to Create a Connected Cluster. + :type connected_cluster: ~azure.mgmt.hybridkubernetes.models.ConnectedCluster + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :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 ConnectedCluster or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridkubernetes.models.ConnectedCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedCluster"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + connected_cluster=connected_cluster, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ConnectedCluster', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + cluster_name: str, + connected_cluster_patch: "_models.ConnectedClusterPatch", + **kwargs + ) -> "_models.ConnectedCluster": + """Updates a connected cluster. + + API to update certain properties of the connected cluster resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_name: The name of the Kubernetes cluster on which get is called. + :type cluster_name: str + :param connected_cluster_patch: Parameters supplied to update Connected Cluster. + :type connected_cluster_patch: ~azure.mgmt.hybridkubernetes.models.ConnectedClusterPatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedCluster, or the result of cls(response) + :rtype: ~azure.mgmt.hybridkubernetes.models.ConnectedCluster + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedCluster"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(connected_cluster_patch, 'ConnectedClusterPatch') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConnectedCluster', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + cluster_name: str, + **kwargs + ) -> "_models.ConnectedCluster": + """Get the properties of the specified connected cluster. + + Returns the properties of the specified connected cluster, including name, identity, + properties, and additional cluster details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_name: The name of the Kubernetes cluster on which get is called. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedCluster, or the result of cls(response) + :rtype: ~azure.mgmt.hybridkubernetes.models.ConnectedCluster + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedCluster"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConnectedCluster', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + cluster_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + cluster_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Delete a connected cluster. + + Delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_name: The name of the Kubernetes cluster on which get is called. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore + + async def list_cluster_user_credentials( + self, + resource_group_name: str, + cluster_name: str, + client_proxy: Optional[bool] = None, + client_authentication_details: Optional["_models.AuthenticationDetails"] = None, + **kwargs + ) -> "_models.CredentialResults": + """Gets cluster user credentials of a connected cluster. + + Gets cluster user credentials of the connected cluster with a specified resource group and + name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_name: The name of the Kubernetes cluster on which get is called. + :type cluster_name: str + :param client_proxy: Parameter to indicate whether the request is for client side proxy or not. + :type client_proxy: bool + :param client_authentication_details: Authentication parameters supplied by the user to fetch + credentials for accessing the cluster. + :type client_authentication_details: ~azure.mgmt.hybridkubernetes.models.AuthenticationDetails + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CredentialResults, or the result of cls(response) + :rtype: ~azure.mgmt.hybridkubernetes.models.CredentialResults + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CredentialResults"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.list_cluster_user_credentials.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if client_proxy is not None: + query_parameters['ClientProxy'] = self._serialize.query("client_proxy", client_proxy, 'bool') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if client_authentication_details is not None: + body_content = self._serialize.body(client_authentication_details, 'AuthenticationDetails') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CredentialResults', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_cluster_user_credentials.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}/listClusterUserCredentials'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["_models.ConnectedClusterList"]: + """Lists all connected clusters. + + API to enumerate registered connected K8s clusters under a Resource Group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedClusterList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridkubernetes.models.ConnectedClusterList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedClusterList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ConnectedClusterList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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.Kubernetes/connectedClusters'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["_models.ConnectedClusterList"]: + """Lists all connected clusters. + + API to enumerate registered connected K8s clusters under a Subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedClusterList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridkubernetes.models.ConnectedClusterList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedClusterList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ConnectedClusterList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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.Kubernetes/connectedClusters'} # type: ignore diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/_operations.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/_operations.py new file mode 100644 index 000000000000..c770363bcc1b --- /dev/null +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.hybridkubernetes.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + **kwargs + ) -> AsyncIterable["_models.OperationList"]: + """Lists all of the available API operations for Connected Cluster resource. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridkubernetes.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.get.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get.metadata = {'url': '/providers/Microsoft.Kubernetes/operations'} # type: ignore diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/__init__.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/__init__.py index b6b8458a7602..5067af8b7115 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/__init__.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/__init__.py @@ -1,68 +1,78 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import AzureEntityResource + from ._models_py3 import AuthenticationDetails + from ._models_py3 import AuthenticationDetailsValue from ._models_py3 import ConnectedCluster from ._models_py3 import ConnectedClusterAADProfile from ._models_py3 import ConnectedClusterIdentity + from ._models_py3 import ConnectedClusterList from ._models_py3 import ConnectedClusterPatch from ._models_py3 import CredentialResult from ._models_py3 import CredentialResults - from ._models_py3 import ErrorDetails - from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail + from ._models_py3 import ErrorResponse + from ._models_py3 import HybridConnectionConfig from ._models_py3 import Operation from ._models_py3 import OperationDisplay - from ._models_py3 import ProxyResource + from ._models_py3 import OperationList from ._models_py3 import Resource from ._models_py3 import TrackedResource except (SyntaxError, ImportError): - from ._models import AzureEntityResource - from ._models import ConnectedCluster - from ._models import ConnectedClusterAADProfile - from ._models import ConnectedClusterIdentity - from ._models import ConnectedClusterPatch - from ._models import CredentialResult - from ._models import CredentialResults - from ._models import ErrorDetails - from ._models import ErrorResponse, ErrorResponseException - from ._models import Operation - from ._models import OperationDisplay - from ._models import ProxyResource - from ._models import Resource - from ._models import TrackedResource -from ._paged_models import ConnectedClusterPaged -from ._paged_models import OperationPaged + from ._models import AuthenticationDetails # type: ignore + from ._models import AuthenticationDetailsValue # type: ignore + from ._models import ConnectedCluster # type: ignore + from ._models import ConnectedClusterAADProfile # type: ignore + from ._models import ConnectedClusterIdentity # type: ignore + from ._models import ConnectedClusterList # type: ignore + from ._models import ConnectedClusterPatch # type: ignore + from ._models import CredentialResult # type: ignore + from ._models import CredentialResults # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import HybridConnectionConfig # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationList # type: ignore + from ._models import Resource # type: ignore + from ._models import TrackedResource # type: ignore + from ._connected_kubernetes_client_enums import ( - ResourceIdentityType, + AuthenticationMethod, + ConnectivityStatus, ProvisioningState, + ResourceIdentityType, ) __all__ = [ - 'AzureEntityResource', + 'AuthenticationDetails', + 'AuthenticationDetailsValue', 'ConnectedCluster', 'ConnectedClusterAADProfile', 'ConnectedClusterIdentity', + 'ConnectedClusterList', 'ConnectedClusterPatch', 'CredentialResult', 'CredentialResults', - 'ErrorDetails', - 'ErrorResponse', 'ErrorResponseException', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'HybridConnectionConfig', 'Operation', 'OperationDisplay', - 'ProxyResource', + 'OperationList', 'Resource', 'TrackedResource', - 'ConnectedClusterPaged', - 'OperationPaged', - 'ResourceIdentityType', + 'AuthenticationMethod', + 'ConnectivityStatus', 'ProvisioningState', + 'ResourceIdentityType', ] diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_connected_kubernetes_client_enums.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_connected_kubernetes_client_enums.py index 0f8d53fe2bb1..75840ee05a40 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_connected_kubernetes_client_enums.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_connected_kubernetes_client_enums.py @@ -1,29 +1,63 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum +from enum import Enum, EnumMeta +from six import with_metaclass +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) -class ResourceIdentityType(str, Enum): + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) - none = "None" - system_assigned = "SystemAssigned" +class AuthenticationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The mode of client authentication. + """ -class ProvisioningState(str, Enum): + TOKEN = "Token" - succeeded = "Succeeded" - failed = "Failed" - canceled = "Canceled" - provisioning = "Provisioning" - updating = "Updating" - deleting = "Deleting" - accepted = "Accepted" +class ConnectivityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Represents the connectivity status of the connected cluster. + """ + + CONNECTING = "Connecting" + CONNECTED = "Connected" + OFFLINE = "Offline" + EXPIRED = "Expired" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The current deployment state of connectedClusters. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PROVISIONING = "Provisioning" + UPDATING = "Updating" + DELETING = "Deleting" + ACCEPTED = "Accepted" + +class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity used for the connected cluster. The type 'SystemAssigned, includes a + system created identity. The type 'None' means no identity is assigned to the connected + cluster. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_models.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_models.py index 492f353d8bcc..aa9b700380ed 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_models.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_models.py @@ -1,118 +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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class Resource(Model): - """Resource. +class AuthenticationDetails(msrest.serialization.Model): + """Authentication details of the user. - Variables are only populated by the server, and will be ignored when - sending a request. + All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - :vartype id: str - :ivar name: The name of the resource - :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str + :param authentication_method: Required. The mode of client authentication. Possible values + include: "Token". + :type authentication_method: str or ~azure.mgmt.hybridkubernetes.models.AuthenticationMethod + :param value: Required. Authentication token value. + :type value: ~azure.mgmt.hybridkubernetes.models.AuthenticationDetailsValue """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + 'authentication_method': {'required': True}, + 'value': {'required': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + 'authentication_method': {'key': 'authenticationMethod', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'AuthenticationDetailsValue'}, } - def __init__(self, **kwargs): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None + def __init__( + self, + **kwargs + ): + super(AuthenticationDetails, self).__init__(**kwargs) + self.authentication_method = kwargs['authentication_method'] + self.value = kwargs['value'] + + +class AuthenticationDetailsValue(msrest.serialization.Model): + """Authentication token value. + + :param token: Authentication token. + :type token: str + """ + + _attribute_map = { + 'token': {'key': 'token', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AuthenticationDetailsValue, self).__init__(**kwargs) + self.token = kwargs.get('token', None) -class AzureEntityResource(Resource): - """The resource model definition for a Azure Resource Manager resource with an - etag. +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'etag': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, } - def __init__(self, **kwargs): - super(AzureEntityResource, self).__init__(**kwargs) - self.etag = None - - -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :param location: Required. The geo-location where the resource lives. :type location: str """ @@ -131,55 +133,69 @@ class TrackedResource(Resource): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TrackedResource, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] class ConnectedCluster(TrackedResource): """Represents a connected cluster. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :param location: Required. The geo-location where the resource lives. :type location: str :param identity: Required. The identity of the connected cluster. - :type identity: - ~azure.mgmt.hybridkubernetes.models.ConnectedClusterIdentity - :param agent_public_key_certificate: Required. Base64 encoded public - certificate used by the agent to do the initial handshake to the backend - services in Azure. + :type identity: ~azure.mgmt.hybridkubernetes.models.ConnectedClusterIdentity + :param agent_public_key_certificate: Required. Base64 encoded public certificate used by the + agent to do the initial handshake to the backend services in Azure. :type agent_public_key_certificate: str - :param aad_profile: Required. - :type aad_profile: - ~azure.mgmt.hybridkubernetes.models.ConnectedClusterAADProfile - :ivar kubernetes_version: The Kubernetes version of the connected cluster - resource + :param aad_profile: Required. AAD profile of the connected cluster. + :type aad_profile: ~azure.mgmt.hybridkubernetes.models.ConnectedClusterAADProfile + :ivar kubernetes_version: The Kubernetes version of the connected cluster resource. :vartype kubernetes_version: str - :ivar total_node_count: Number of nodes present in the connected cluster - resource + :ivar total_node_count: Number of nodes present in the connected cluster resource. :vartype total_node_count: int - :ivar agent_version: Version of the agent running on the connected cluster - resource + :ivar total_core_count: Number of CPU cores present in the connected cluster resource. + :vartype total_core_count: int + :ivar agent_version: Version of the agent running on the connected cluster resource. :vartype agent_version: str - :param provisioning_state: Possible values include: 'Succeeded', 'Failed', - 'Canceled', 'Provisioning', 'Updating', 'Deleting', 'Accepted' - :type provisioning_state: str or - ~azure.mgmt.hybridkubernetes.models.ProvisioningState + :param provisioning_state: Provisioning state of the connected cluster resource. Possible + values include: "Succeeded", "Failed", "Canceled", "Provisioning", "Updating", "Deleting", + "Accepted". + :type provisioning_state: str or ~azure.mgmt.hybridkubernetes.models.ProvisioningState + :param distribution: The Kubernetes distribution running on this connected cluster. + :type distribution: str + :param infrastructure: The infrastructure on which the Kubernetes cluster represented by this + connected cluster is running on. + :type infrastructure: str + :ivar offering: Connected cluster offering. + :vartype offering: str + :ivar managed_identity_certificate_expiration_time: Expiration time of the managed identity + certificate. + :vartype managed_identity_certificate_expiration_time: ~datetime.datetime + :ivar last_connectivity_time: Time representing the last instance when heart beat was received + from the cluster. + :vartype last_connectivity_time: ~datetime.datetime + :param connectivity_status: Represents the connectivity status of the connected cluster. + Possible values include: "Connecting", "Connected", "Offline", "Expired". + :type connectivity_status: str or ~azure.mgmt.hybridkubernetes.models.ConnectivityStatus """ _validation = { @@ -192,7 +208,11 @@ class ConnectedCluster(TrackedResource): 'aad_profile': {'required': True}, 'kubernetes_version': {'readonly': True}, 'total_node_count': {'readonly': True}, + 'total_core_count': {'readonly': True}, 'agent_version': {'readonly': True}, + 'offering': {'readonly': True}, + 'managed_identity_certificate_expiration_time': {'readonly': True}, + 'last_connectivity_time': {'readonly': True}, } _attribute_map = { @@ -206,33 +226,48 @@ class ConnectedCluster(TrackedResource): 'aad_profile': {'key': 'properties.aadProfile', 'type': 'ConnectedClusterAADProfile'}, 'kubernetes_version': {'key': 'properties.kubernetesVersion', 'type': 'str'}, 'total_node_count': {'key': 'properties.totalNodeCount', 'type': 'int'}, + 'total_core_count': {'key': 'properties.totalCoreCount', 'type': 'int'}, 'agent_version': {'key': 'properties.agentVersion', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'distribution': {'key': 'properties.distribution', 'type': 'str'}, + 'infrastructure': {'key': 'properties.infrastructure', 'type': 'str'}, + 'offering': {'key': 'properties.offering', 'type': 'str'}, + 'managed_identity_certificate_expiration_time': {'key': 'properties.managedIdentityCertificateExpirationTime', 'type': 'iso-8601'}, + 'last_connectivity_time': {'key': 'properties.lastConnectivityTime', 'type': 'iso-8601'}, + 'connectivity_status': {'key': 'properties.connectivityStatus', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ConnectedCluster, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.agent_public_key_certificate = kwargs.get('agent_public_key_certificate', None) - self.aad_profile = kwargs.get('aad_profile', None) + self.identity = kwargs['identity'] + self.agent_public_key_certificate = kwargs['agent_public_key_certificate'] + self.aad_profile = kwargs['aad_profile'] self.kubernetes_version = None self.total_node_count = None + self.total_core_count = None self.agent_version = None self.provisioning_state = kwargs.get('provisioning_state', None) + self.distribution = kwargs.get('distribution', None) + self.infrastructure = kwargs.get('infrastructure', None) + self.offering = None + self.managed_identity_certificate_expiration_time = None + self.last_connectivity_time = None + self.connectivity_status = kwargs.get('connectivity_status', None) -class ConnectedClusterAADProfile(Model): - """ConnectedClusterAADProfile. +class ConnectedClusterAADProfile(msrest.serialization.Model): + """AAD profile of the connected cluster. All required parameters must be populated in order to send to Azure. - :param tenant_id: Required. The aad tenant id which is configured on - target K8s cluster + :param tenant_id: Required. The aad tenant id which is configured on target K8s cluster. :type tenant_id: str - :param client_app_id: Required. The client app id configured on target K8 - cluster + :param client_app_id: Required. The client app id configured on target K8 cluster. :type client_app_id: str - :param server_app_id: Required. The server app id to access AD server + :param server_app_id: Required. The server app id to access AD server. :type server_app_id: str """ @@ -248,33 +283,33 @@ class ConnectedClusterAADProfile(Model): 'server_app_id': {'key': 'serverAppId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ConnectedClusterAADProfile, self).__init__(**kwargs) - self.tenant_id = kwargs.get('tenant_id', None) - self.client_app_id = kwargs.get('client_app_id', None) - self.server_app_id = kwargs.get('server_app_id', None) + self.tenant_id = kwargs['tenant_id'] + self.client_app_id = kwargs['client_app_id'] + self.server_app_id = kwargs['server_app_id'] -class ConnectedClusterIdentity(Model): +class ConnectedClusterIdentity(msrest.serialization.Model): """Identity for the connected cluster. - Variables are only populated by the server, and will be ignored when - sending a request. + 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 principal_id: The principal id of connected cluster identity. This - property will only be provided for a system assigned identity. + :ivar principal_id: The principal id of connected cluster identity. This property will only be + provided for a system assigned identity. :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the connected cluster. This - property will only be provided for a system assigned identity. + :ivar tenant_id: The tenant id associated with the connected cluster. This property will only + be provided for a system assigned identity. :vartype tenant_id: str - :param type: Required. The type of identity used for the connected - cluster. The type 'SystemAssigned, includes a system created identity. The - type 'None' means no identity is assigned to the connected cluster. - Possible values include: 'None', 'SystemAssigned' - :type type: str or - ~azure.mgmt.hybridkubernetes.models.ResourceIdentityType + :param type: Required. The type of identity used for the connected cluster. The type + 'SystemAssigned, includes a system created identity. The type 'None' means no identity is + assigned to the connected cluster. Possible values include: "None", "SystemAssigned". + :type type: str or ~azure.mgmt.hybridkubernetes.models.ResourceIdentityType """ _validation = { @@ -286,24 +321,49 @@ class ConnectedClusterIdentity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ConnectedClusterIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = kwargs.get('type', None) + self.type = kwargs['type'] -class ConnectedClusterPatch(Model): +class ConnectedClusterList(msrest.serialization.Model): + """The paginated list of connected Clusters. + + :param value: The list of connected clusters. + :type value: list[~azure.mgmt.hybridkubernetes.models.ConnectedCluster] + :param next_link: The link to fetch the next page of connected cluster. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ConnectedCluster]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ConnectedClusterList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ConnectedClusterPatch(msrest.serialization.Model): """Object containing updates for patch operations. - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param agent_public_key_certificate: Base64 encoded public certificate - used by the agent to do the initial handshake to the backend services in - Azure. + :param agent_public_key_certificate: Base64 encoded public certificate used by the agent to do + the initial handshake to the backend services in Azure. :type agent_public_key_certificate: str """ @@ -312,17 +372,19 @@ class ConnectedClusterPatch(Model): 'agent_public_key_certificate': {'key': 'properties.agentPublicKeyCertificate', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ConnectedClusterPatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.agent_public_key_certificate = kwargs.get('agent_public_key_certificate', None) -class CredentialResult(Model): +class CredentialResult(msrest.serialization.Model): """The credential result response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of the credential. :vartype name: str @@ -340,99 +402,186 @@ class CredentialResult(Model): 'value': {'key': 'value', 'type': 'bytearray'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CredentialResult, self).__init__(**kwargs) self.name = None self.value = None -class CredentialResults(Model): +class CredentialResults(msrest.serialization.Model): """The list of credential result response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar hybrid_connection_config: Contains the REP (rendezvous endpoint) and “Sender” access + token. + :vartype hybrid_connection_config: ~azure.mgmt.hybridkubernetes.models.HybridConnectionConfig :ivar kubeconfigs: Base64-encoded Kubernetes configuration file. - :vartype kubeconfigs: - list[~azure.mgmt.hybridkubernetes.models.CredentialResult] + :vartype kubeconfigs: list[~azure.mgmt.hybridkubernetes.models.CredentialResult] """ _validation = { + 'hybrid_connection_config': {'readonly': True}, 'kubeconfigs': {'readonly': True}, } _attribute_map = { + 'hybrid_connection_config': {'key': 'hybridConnectionConfig', 'type': 'HybridConnectionConfig'}, 'kubeconfigs': {'key': 'kubeconfigs', 'type': '[CredentialResult]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CredentialResults, self).__init__(**kwargs) + self.hybrid_connection_config = None self.kubeconfigs = None -class ErrorDetails(Model): - """The error response details containing error code and error message. +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: object + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + - Variables are only populated by the server, and will be ignored when - sending a request. +class ErrorDetail(msrest.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.hybridkubernetes.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.hybridkubernetes.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): - super(ErrorDetails, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None + self.target = None + self.details = None + self.additional_info = None -class ErrorResponse(Model): - """The error response that indicates why an operation has failed. +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: - :type error: ~azure.mgmt.hybridkubernetes.models.ErrorDetails + :param error: The error object. + :type error: ~azure.mgmt.hybridkubernetes.models.ErrorDetail """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetails'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. +class HybridConnectionConfig(msrest.serialization.Model): + """Contains the REP (rendezvous endpoint) and “Sender” access token. + + Variables are only populated by the server, and will be ignored when sending a request. - :param deserialize: A deserializer - :param response: Server response to be deserialized. + :ivar expiration_time: Timestamp when this token will be expired. + :vartype expiration_time: long + :ivar hybrid_connection_name: Name of the connection. + :vartype hybrid_connection_name: str + :ivar relay: Name of the relay. + :vartype relay: str + :ivar token: Sender access token. + :vartype token: str """ - def __init__(self, deserialize, response, *args): + _validation = { + 'expiration_time': {'readonly': True}, + 'hybrid_connection_name': {'readonly': True}, + 'relay': {'readonly': True}, + 'token': {'readonly': True}, + } - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + _attribute_map = { + 'expiration_time': {'key': 'expirationTime', 'type': 'long'}, + 'hybrid_connection_name': {'key': 'hybridConnectionName', 'type': 'str'}, + 'relay': {'key': 'relay', 'type': 'str'}, + 'token': {'key': 'token', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(HybridConnectionConfig, self).__init__(**kwargs) + self.expiration_time = None + self.hybrid_connection_name = None + self.relay = None + self.token = None -class Operation(Model): +class Operation(msrest.serialization.Model): """The Connected cluster API operation. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: Operation name: {Microsoft.Kubernetes}/{resource}/{operation} + :ivar name: Operation name: {Microsoft.Kubernetes}/{resource}/{operation}. :vartype name: str :ivar display: The object that represents the operation. :vartype display: ~azure.mgmt.hybridkubernetes.models.OperationDisplay @@ -448,19 +597,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = None self.display = None -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.connectedClusters + :param provider: Service provider: Microsoft.connectedClusters. :type provider: str - :param resource: Connected Cluster Resource on which the operation is - performed + :param resource: Connected Cluster Resource on which the operation is performed. :type resource: str :param operation: Operation type: Read, write, delete, etc. :type operation: str @@ -475,7 +626,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -483,34 +637,30 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have - everything other than required location and tags. +class OperationList(msrest.serialization.Model): + """The paginated list of connected cluster API operations. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - :vartype id: str - :ivar name: The name of the resource - :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str + :ivar value: The list of connected cluster API operations. + :vartype value: list[~azure.mgmt.hybridkubernetes.models.Operation] + :param next_link: The link to fetch the next page of connected cluster API operations. + :type next_link: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + 'value': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): - super(ProxyResource, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(OperationList, self).__init__(**kwargs) + self.value = None + self.next_link = kwargs.get('next_link', None) diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_models_py3.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_models_py3.py index e31f6f78bae0..a3ca24ac88f9 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_models_py3.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_models_py3.py @@ -1,118 +1,129 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class Resource(Model): - """Resource. +from ._connected_kubernetes_client_enums import * - Variables are only populated by the server, and will be ignored when - sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - :vartype id: str - :ivar name: The name of the resource - :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str +class AuthenticationDetails(msrest.serialization.Model): + """Authentication details of the user. + + All required parameters must be populated in order to send to Azure. + + :param authentication_method: Required. The mode of client authentication. Possible values + include: "Token". + :type authentication_method: str or ~azure.mgmt.hybridkubernetes.models.AuthenticationMethod + :param value: Required. Authentication token value. + :type value: ~azure.mgmt.hybridkubernetes.models.AuthenticationDetailsValue """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + 'authentication_method': {'required': True}, + 'value': {'required': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + 'authentication_method': {'key': 'authenticationMethod', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'AuthenticationDetailsValue'}, } - def __init__(self, **kwargs) -> None: - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None + def __init__( + self, + *, + authentication_method: Union[str, "AuthenticationMethod"], + value: "AuthenticationDetailsValue", + **kwargs + ): + super(AuthenticationDetails, self).__init__(**kwargs) + self.authentication_method = authentication_method + self.value = value + + +class AuthenticationDetailsValue(msrest.serialization.Model): + """Authentication token value. + + :param token: Authentication token. + :type token: str + """ + + _attribute_map = { + 'token': {'key': 'token', 'type': 'str'}, + } + + def __init__( + self, + *, + token: Optional[str] = None, + **kwargs + ): + super(AuthenticationDetailsValue, self).__init__(**kwargs) + self.token = token -class AzureEntityResource(Resource): - """The resource model definition for a Azure Resource Manager resource with an - etag. +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'etag': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: - super(AzureEntityResource, self).__init__(**kwargs) - self.etag = None - - -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :param location: Required. The geo-location where the resource lives. :type location: str """ @@ -131,7 +142,13 @@ class TrackedResource(Resource): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, *, location: str, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -140,46 +157,57 @@ def __init__(self, *, location: str, tags=None, **kwargs) -> None: class ConnectedCluster(TrackedResource): """Represents a connected cluster. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :param location: Required. The geo-location where the resource lives. :type location: str :param identity: Required. The identity of the connected cluster. - :type identity: - ~azure.mgmt.hybridkubernetes.models.ConnectedClusterIdentity - :param agent_public_key_certificate: Required. Base64 encoded public - certificate used by the agent to do the initial handshake to the backend - services in Azure. + :type identity: ~azure.mgmt.hybridkubernetes.models.ConnectedClusterIdentity + :param agent_public_key_certificate: Required. Base64 encoded public certificate used by the + agent to do the initial handshake to the backend services in Azure. :type agent_public_key_certificate: str - :param aad_profile: Required. - :type aad_profile: - ~azure.mgmt.hybridkubernetes.models.ConnectedClusterAADProfile - :ivar kubernetes_version: The Kubernetes version of the connected cluster - resource + :param aad_profile: Required. AAD profile of the connected cluster. + :type aad_profile: ~azure.mgmt.hybridkubernetes.models.ConnectedClusterAADProfile + :ivar kubernetes_version: The Kubernetes version of the connected cluster resource. :vartype kubernetes_version: str - :ivar total_node_count: Number of nodes present in the connected cluster - resource + :ivar total_node_count: Number of nodes present in the connected cluster resource. :vartype total_node_count: int - :ivar agent_version: Version of the agent running on the connected cluster - resource + :ivar total_core_count: Number of CPU cores present in the connected cluster resource. + :vartype total_core_count: int + :ivar agent_version: Version of the agent running on the connected cluster resource. :vartype agent_version: str - :param provisioning_state: Possible values include: 'Succeeded', 'Failed', - 'Canceled', 'Provisioning', 'Updating', 'Deleting', 'Accepted' - :type provisioning_state: str or - ~azure.mgmt.hybridkubernetes.models.ProvisioningState + :param provisioning_state: Provisioning state of the connected cluster resource. Possible + values include: "Succeeded", "Failed", "Canceled", "Provisioning", "Updating", "Deleting", + "Accepted". + :type provisioning_state: str or ~azure.mgmt.hybridkubernetes.models.ProvisioningState + :param distribution: The Kubernetes distribution running on this connected cluster. + :type distribution: str + :param infrastructure: The infrastructure on which the Kubernetes cluster represented by this + connected cluster is running on. + :type infrastructure: str + :ivar offering: Connected cluster offering. + :vartype offering: str + :ivar managed_identity_certificate_expiration_time: Expiration time of the managed identity + certificate. + :vartype managed_identity_certificate_expiration_time: ~datetime.datetime + :ivar last_connectivity_time: Time representing the last instance when heart beat was received + from the cluster. + :vartype last_connectivity_time: ~datetime.datetime + :param connectivity_status: Represents the connectivity status of the connected cluster. + Possible values include: "Connecting", "Connected", "Offline", "Expired". + :type connectivity_status: str or ~azure.mgmt.hybridkubernetes.models.ConnectivityStatus """ _validation = { @@ -192,7 +220,11 @@ class ConnectedCluster(TrackedResource): 'aad_profile': {'required': True}, 'kubernetes_version': {'readonly': True}, 'total_node_count': {'readonly': True}, + 'total_core_count': {'readonly': True}, 'agent_version': {'readonly': True}, + 'offering': {'readonly': True}, + 'managed_identity_certificate_expiration_time': {'readonly': True}, + 'last_connectivity_time': {'readonly': True}, } _attribute_map = { @@ -206,33 +238,58 @@ class ConnectedCluster(TrackedResource): 'aad_profile': {'key': 'properties.aadProfile', 'type': 'ConnectedClusterAADProfile'}, 'kubernetes_version': {'key': 'properties.kubernetesVersion', 'type': 'str'}, 'total_node_count': {'key': 'properties.totalNodeCount', 'type': 'int'}, + 'total_core_count': {'key': 'properties.totalCoreCount', 'type': 'int'}, 'agent_version': {'key': 'properties.agentVersion', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'distribution': {'key': 'properties.distribution', 'type': 'str'}, + 'infrastructure': {'key': 'properties.infrastructure', 'type': 'str'}, + 'offering': {'key': 'properties.offering', 'type': 'str'}, + 'managed_identity_certificate_expiration_time': {'key': 'properties.managedIdentityCertificateExpirationTime', 'type': 'iso-8601'}, + 'last_connectivity_time': {'key': 'properties.lastConnectivityTime', 'type': 'iso-8601'}, + 'connectivity_status': {'key': 'properties.connectivityStatus', 'type': 'str'}, } - def __init__(self, *, location: str, identity, agent_public_key_certificate: str, aad_profile, tags=None, provisioning_state=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + identity: "ConnectedClusterIdentity", + agent_public_key_certificate: str, + aad_profile: "ConnectedClusterAADProfile", + tags: Optional[Dict[str, str]] = None, + provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + distribution: Optional[str] = None, + infrastructure: Optional[str] = None, + connectivity_status: Optional[Union[str, "ConnectivityStatus"]] = None, + **kwargs + ): super(ConnectedCluster, self).__init__(tags=tags, location=location, **kwargs) self.identity = identity self.agent_public_key_certificate = agent_public_key_certificate self.aad_profile = aad_profile self.kubernetes_version = None self.total_node_count = None + self.total_core_count = None self.agent_version = None self.provisioning_state = provisioning_state + self.distribution = distribution + self.infrastructure = infrastructure + self.offering = None + self.managed_identity_certificate_expiration_time = None + self.last_connectivity_time = None + self.connectivity_status = connectivity_status -class ConnectedClusterAADProfile(Model): - """ConnectedClusterAADProfile. +class ConnectedClusterAADProfile(msrest.serialization.Model): + """AAD profile of the connected cluster. All required parameters must be populated in order to send to Azure. - :param tenant_id: Required. The aad tenant id which is configured on - target K8s cluster + :param tenant_id: Required. The aad tenant id which is configured on target K8s cluster. :type tenant_id: str - :param client_app_id: Required. The client app id configured on target K8 - cluster + :param client_app_id: Required. The client app id configured on target K8 cluster. :type client_app_id: str - :param server_app_id: Required. The server app id to access AD server + :param server_app_id: Required. The server app id to access AD server. :type server_app_id: str """ @@ -248,33 +305,37 @@ class ConnectedClusterAADProfile(Model): 'server_app_id': {'key': 'serverAppId', 'type': 'str'}, } - def __init__(self, *, tenant_id: str, client_app_id: str, server_app_id: str, **kwargs) -> None: + def __init__( + self, + *, + tenant_id: str, + client_app_id: str, + server_app_id: str, + **kwargs + ): super(ConnectedClusterAADProfile, self).__init__(**kwargs) self.tenant_id = tenant_id self.client_app_id = client_app_id self.server_app_id = server_app_id -class ConnectedClusterIdentity(Model): +class ConnectedClusterIdentity(msrest.serialization.Model): """Identity for the connected cluster. - Variables are only populated by the server, and will be ignored when - sending a request. + 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 principal_id: The principal id of connected cluster identity. This - property will only be provided for a system assigned identity. + :ivar principal_id: The principal id of connected cluster identity. This property will only be + provided for a system assigned identity. :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the connected cluster. This - property will only be provided for a system assigned identity. + :ivar tenant_id: The tenant id associated with the connected cluster. This property will only + be provided for a system assigned identity. :vartype tenant_id: str - :param type: Required. The type of identity used for the connected - cluster. The type 'SystemAssigned, includes a system created identity. The - type 'None' means no identity is assigned to the connected cluster. - Possible values include: 'None', 'SystemAssigned' - :type type: str or - ~azure.mgmt.hybridkubernetes.models.ResourceIdentityType + :param type: Required. The type of identity used for the connected cluster. The type + 'SystemAssigned, includes a system created identity. The type 'None' means no identity is + assigned to the connected cluster. Possible values include: "None", "SystemAssigned". + :type type: str or ~azure.mgmt.hybridkubernetes.models.ResourceIdentityType """ _validation = { @@ -286,24 +347,54 @@ class ConnectedClusterIdentity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type, **kwargs) -> None: + def __init__( + self, + *, + type: Union[str, "ResourceIdentityType"], + **kwargs + ): super(ConnectedClusterIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ConnectedClusterPatch(Model): +class ConnectedClusterList(msrest.serialization.Model): + """The paginated list of connected Clusters. + + :param value: The list of connected clusters. + :type value: list[~azure.mgmt.hybridkubernetes.models.ConnectedCluster] + :param next_link: The link to fetch the next page of connected cluster. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ConnectedCluster]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ConnectedCluster"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ConnectedClusterList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ConnectedClusterPatch(msrest.serialization.Model): """Object containing updates for patch operations. - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param agent_public_key_certificate: Base64 encoded public certificate - used by the agent to do the initial handshake to the backend services in - Azure. + :param agent_public_key_certificate: Base64 encoded public certificate used by the agent to do + the initial handshake to the backend services in Azure. :type agent_public_key_certificate: str """ @@ -312,17 +403,22 @@ class ConnectedClusterPatch(Model): 'agent_public_key_certificate': {'key': 'properties.agentPublicKeyCertificate', 'type': 'str'}, } - def __init__(self, *, tags=None, agent_public_key_certificate: str=None, **kwargs) -> None: + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + agent_public_key_certificate: Optional[str] = None, + **kwargs + ): super(ConnectedClusterPatch, self).__init__(**kwargs) self.tags = tags self.agent_public_key_certificate = agent_public_key_certificate -class CredentialResult(Model): +class CredentialResult(msrest.serialization.Model): """The credential result response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of the credential. :vartype name: str @@ -340,99 +436,188 @@ class CredentialResult(Model): 'value': {'key': 'value', 'type': 'bytearray'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(CredentialResult, self).__init__(**kwargs) self.name = None self.value = None -class CredentialResults(Model): +class CredentialResults(msrest.serialization.Model): """The list of credential result response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar hybrid_connection_config: Contains the REP (rendezvous endpoint) and “Sender” access + token. + :vartype hybrid_connection_config: ~azure.mgmt.hybridkubernetes.models.HybridConnectionConfig :ivar kubeconfigs: Base64-encoded Kubernetes configuration file. - :vartype kubeconfigs: - list[~azure.mgmt.hybridkubernetes.models.CredentialResult] + :vartype kubeconfigs: list[~azure.mgmt.hybridkubernetes.models.CredentialResult] """ _validation = { + 'hybrid_connection_config': {'readonly': True}, 'kubeconfigs': {'readonly': True}, } _attribute_map = { + 'hybrid_connection_config': {'key': 'hybridConnectionConfig', 'type': 'HybridConnectionConfig'}, 'kubeconfigs': {'key': 'kubeconfigs', 'type': '[CredentialResult]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(CredentialResults, self).__init__(**kwargs) + self.hybrid_connection_config = None self.kubeconfigs = None -class ErrorDetails(Model): - """The error response details containing error code and error message. +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: object + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. - Variables are only populated by the server, and will be ignored when - sending a request. + 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.hybridkubernetes.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.hybridkubernetes.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) -> None: - super(ErrorDetails, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None + self.target = None + self.details = None + self.additional_info = None -class ErrorResponse(Model): - """The error response that indicates why an operation has failed. +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: - :type error: ~azure.mgmt.hybridkubernetes.models.ErrorDetails + :param error: The error object. + :type error: ~azure.mgmt.hybridkubernetes.models.ErrorDetail """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetails'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, } - def __init__(self, *, error=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.error = error -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. +class HybridConnectionConfig(msrest.serialization.Model): + """Contains the REP (rendezvous endpoint) and “Sender” access token. + + Variables are only populated by the server, and will be ignored when sending a request. - :param deserialize: A deserializer - :param response: Server response to be deserialized. + :ivar expiration_time: Timestamp when this token will be expired. + :vartype expiration_time: long + :ivar hybrid_connection_name: Name of the connection. + :vartype hybrid_connection_name: str + :ivar relay: Name of the relay. + :vartype relay: str + :ivar token: Sender access token. + :vartype token: str """ - def __init__(self, deserialize, response, *args): + _validation = { + 'expiration_time': {'readonly': True}, + 'hybrid_connection_name': {'readonly': True}, + 'relay': {'readonly': True}, + 'token': {'readonly': True}, + } + + _attribute_map = { + 'expiration_time': {'key': 'expirationTime', 'type': 'long'}, + 'hybrid_connection_name': {'key': 'hybridConnectionName', 'type': 'str'}, + 'relay': {'key': 'relay', 'type': 'str'}, + 'token': {'key': 'token', 'type': 'str'}, + } - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + def __init__( + self, + **kwargs + ): + super(HybridConnectionConfig, self).__init__(**kwargs) + self.expiration_time = None + self.hybrid_connection_name = None + self.relay = None + self.token = None -class Operation(Model): +class Operation(msrest.serialization.Model): """The Connected cluster API operation. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: Operation name: {Microsoft.Kubernetes}/{resource}/{operation} + :ivar name: Operation name: {Microsoft.Kubernetes}/{resource}/{operation}. :vartype name: str :ivar display: The object that represents the operation. :vartype display: ~azure.mgmt.hybridkubernetes.models.OperationDisplay @@ -448,19 +633,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = None self.display = None -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.connectedClusters + :param provider: Service provider: Microsoft.connectedClusters. :type provider: str - :param resource: Connected Cluster Resource on which the operation is - performed + :param resource: Connected Cluster Resource on which the operation is performed. :type resource: str :param operation: Operation type: Read, write, delete, etc. :type operation: str @@ -475,7 +662,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -483,34 +678,32 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have - everything other than required location and tags. +class OperationList(msrest.serialization.Model): + """The paginated list of connected cluster API operations. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - :vartype id: str - :ivar name: The name of the resource - :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str + :ivar value: The list of connected cluster API operations. + :vartype value: list[~azure.mgmt.hybridkubernetes.models.Operation] + :param next_link: The link to fetch the next page of connected cluster API operations. + :type next_link: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + 'value': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: - super(ProxyResource, self).__init__(**kwargs) + def __init__( + self, + *, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationList, self).__init__(**kwargs) + self.value = None + self.next_link = next_link diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_paged_models.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_paged_models.py deleted file mode 100644 index 35645bf060b2..000000000000 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/models/_paged_models.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class ConnectedClusterPaged(Paged): - """ - A paging container for iterating over a list of :class:`ConnectedCluster ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ConnectedCluster]'} - } - - def __init__(self, *args, **kwargs): - - super(ConnectedClusterPaged, self).__init__(*args, **kwargs) -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/__init__.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/__init__.py index ae3f9846891a..4bf80ae81ea0 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/__init__.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/__init__.py @@ -1,12 +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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._connected_cluster_operations import ConnectedClusterOperations diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/_connected_cluster_operations.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/_connected_cluster_operations.py index 5629cc7b43ea..94618ee551a6 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/_connected_cluster_operations.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/_connected_cluster_operations.py @@ -1,578 +1,652 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models +from .. import models as _models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ConnectedClusterOperations(object): """ConnectedClusterOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.hybridkubernetes.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2020-01-01-preview". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2020-01-01-preview" - - self.config = config - + self._config = config def _create_initial( - self, resource_group_name, cluster_name, connected_cluster, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + cluster_name, # type: str + connected_cluster, # type: "_models.ConnectedCluster" + **kwargs # type: Any + ): + # type: (...) -> "_models.ConnectedCluster" + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedCluster"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create.metadata['url'] + url = self._create_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str') + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(connected_cluster, 'ConnectedCluster') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(connected_cluster, 'ConnectedCluster') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ConnectedCluster', response) + deserialized = self._deserialize('ConnectedCluster', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ConnectedCluster', response) + deserialized = self._deserialize('ConnectedCluster', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create( - self, resource_group_name, cluster_name, connected_cluster, custom_headers=None, raw=False, polling=True, **operation_config): + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore + + def begin_create( + self, + resource_group_name, # type: str + cluster_name, # type: str + connected_cluster, # type: "_models.ConnectedCluster" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.ConnectedCluster"] """Register a new Kubernetes cluster with Azure Resource Manager. - API to register a new Kubernetes cluster and create a tracked resource - in Azure Resource Manager (ARM). + API to register a new Kubernetes cluster and create a tracked resource in Azure Resource + Manager (ARM). - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param cluster_name: The name of the Kubernetes cluster on which get - is called. + :param cluster_name: The name of the Kubernetes cluster on which get is called. :type cluster_name: str - :param connected_cluster: Parameters supplied to Create a Connected - Cluster. - :type connected_cluster: - ~azure.mgmt.hybridkubernetes.models.ConnectedCluster - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param connected_cluster: Parameters supplied to Create a Connected Cluster. + :type connected_cluster: ~azure.mgmt.hybridkubernetes.models.ConnectedCluster + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns ConnectedCluster or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.hybridkubernetes.models.ConnectedCluster] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.hybridkubernetes.models.ConnectedCluster]] - :raises: - :class:`ErrorResponseException` + :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 ConnectedCluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridkubernetes.models.ConnectedCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._create_initial( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - connected_cluster=connected_cluster, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedCluster"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ConnectedCluster', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + connected_cluster=connected_cluster, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ConnectedCluster', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore def update( - self, resource_group_name, cluster_name, tags=None, agent_public_key_certificate=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + cluster_name, # type: str + connected_cluster_patch, # type: "_models.ConnectedClusterPatch" + **kwargs # type: Any + ): + # type: (...) -> "_models.ConnectedCluster" """Updates a connected cluster. API to update certain properties of the connected cluster resource. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param cluster_name: The name of the Kubernetes cluster on which get - is called. + :param cluster_name: The name of the Kubernetes cluster on which get is called. :type cluster_name: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param agent_public_key_certificate: Base64 encoded public certificate - used by the agent to do the initial handshake to the backend services - in Azure. - :type agent_public_key_certificate: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ConnectedCluster or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.hybridkubernetes.models.ConnectedCluster or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param connected_cluster_patch: Parameters supplied to update Connected Cluster. + :type connected_cluster_patch: ~azure.mgmt.hybridkubernetes.models.ConnectedClusterPatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedCluster, or the result of cls(response) + :rtype: ~azure.mgmt.hybridkubernetes.models.ConnectedCluster + :raises: ~azure.core.exceptions.HttpResponseError """ - connected_cluster_patch = models.ConnectedClusterPatch(tags=tags, agent_public_key_certificate=agent_public_key_certificate) + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedCluster"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str') + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(connected_cluster_patch, 'ConnectedClusterPatch') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(connected_cluster_patch, 'ConnectedClusterPatch') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ConnectedCluster', response) + deserialized = self._deserialize('ConnectedCluster', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore def get( - self, resource_group_name, cluster_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + cluster_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ConnectedCluster" """Get the properties of the specified connected cluster. - Returns the properties of the specified connected cluster, including - name, identity, properties, and additional cluster details. + Returns the properties of the specified connected cluster, including name, identity, + properties, and additional cluster details. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param cluster_name: The name of the Kubernetes cluster on which get - is called. + :param cluster_name: The name of the Kubernetes cluster on which get is called. :type cluster_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ConnectedCluster or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.hybridkubernetes.models.ConnectedCluster or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedCluster, or the result of cls(response) + :rtype: ~azure.mgmt.hybridkubernetes.models.ConnectedCluster + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedCluster"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str') + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ConnectedCluster', response) + deserialized = self._deserialize('ConnectedCluster', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} - + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore def _delete_initial( - self, resource_group_name, cluster_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + cluster_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self._delete_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str') + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - raise models.ErrorResponseException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, cluster_name, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + cluster_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] """Delete a connected cluster. - Delete a connected cluster, removing the tracked resource in Azure - Resource Manager (ARM). + Delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM). - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param cluster_name: The name of the Kubernetes cluster on which get - is called. + :param cluster_name: The name of the Kubernetes cluster on which get is called. :type cluster_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`ErrorResponseException` + :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: """ - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + } - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'} # type: ignore def list_cluster_user_credentials( - self, resource_group_name, cluster_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + cluster_name, # type: str + client_proxy=None, # type: Optional[bool] + client_authentication_details=None, # type: Optional["_models.AuthenticationDetails"] + **kwargs # type: Any + ): + # type: (...) -> "_models.CredentialResults" """Gets cluster user credentials of a connected cluster. - Gets cluster user credentials of the connected cluster with a specified - resource group and name. + Gets cluster user credentials of the connected cluster with a specified resource group and + name. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param cluster_name: The name of the Kubernetes cluster on which get - is called. + :param cluster_name: The name of the Kubernetes cluster on which get is called. :type cluster_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CredentialResults or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.hybridkubernetes.models.CredentialResults or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param client_proxy: Parameter to indicate whether the request is for client side proxy or not. + :type client_proxy: bool + :param client_authentication_details: Authentication parameters supplied by the user to fetch + credentials for accessing the cluster. + :type client_authentication_details: ~azure.mgmt.hybridkubernetes.models.AuthenticationDetails + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CredentialResults, or the result of cls(response) + :rtype: ~azure.mgmt.hybridkubernetes.models.CredentialResults + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CredentialResults"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.list_cluster_user_credentials.metadata['url'] + url = self.list_cluster_user_credentials.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str') + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if client_proxy is not None: + query_parameters['ClientProxy'] = self._serialize.query("client_proxy", client_proxy, 'bool') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if client_authentication_details is not None: + body_content = self._serialize.body(client_authentication_details, 'AuthenticationDetails') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CredentialResults', response) + deserialized = self._deserialize('CredentialResults', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_cluster_user_credentials.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}/listClusterUserCredentials'} + list_cluster_user_credentials.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}/listClusterUserCredentials'} # type: ignore def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ConnectedClusterList"] """Lists all connected clusters. - API to enumerate registered connected K8s clusters under a Resource - Group. + API to enumerate registered connected K8s clusters under a Resource Group. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ConnectedCluster - :rtype: - ~azure.mgmt.hybridkubernetes.models.ConnectedClusterPaged[~azure.mgmt.hybridkubernetes.models.ConnectedCluster] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedClusterList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridkubernetes.models.ConnectedClusterList] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedClusterList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['url'] + url = self.list_by_resource_group.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ConnectedClusterList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ConnectedClusterPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters'} # type: ignore def list_by_subscription( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ConnectedClusterList"] """Lists all connected clusters. - API to enumerate registered connected K8s clusters under a - Subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ConnectedCluster - :rtype: - ~azure.mgmt.hybridkubernetes.models.ConnectedClusterPaged[~azure.mgmt.hybridkubernetes.models.ConnectedCluster] - :raises: - :class:`ErrorResponseException` + API to enumerate registered connected K8s clusters under a Subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedClusterList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridkubernetes.models.ConnectedClusterList] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedClusterList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_subscription.metadata['url'] + url = self.list_by_subscription.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ConnectedClusterList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ConnectedClusterPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kubernetes/connectedClusters'} + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kubernetes/connectedClusters'} # type: ignore diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/_operations.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/_operations.py index 9c3239ad4ccb..29e420a46c50 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/_operations.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/operations/_operations.py @@ -1,101 +1,110 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models +from .. import models as _models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.hybridkubernetes.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2020-01-01-preview". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2020-01-01-preview" - - self.config = config + self._config = config def get( - self, custom_headers=None, raw=False, **operation_config): - """Lists all of the available API operations for Connected Cluster - resource. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.hybridkubernetes.models.OperationPaged[~azure.mgmt.hybridkubernetes.models.Operation] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OperationList"] + """Lists all of the available API operations for Connected Cluster resource. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridkubernetes.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-01-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.get.metadata['url'] - + url = self.get.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - get.metadata = {'url': '/providers/Microsoft.Kubernetes/operations'} + return ItemPaged( + get_next, extract_data + ) + get.metadata = {'url': '/providers/Microsoft.Kubernetes/operations'} # type: ignore diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/py.typed b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/azure/mgmt/hybridkubernetes/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/setup.py b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/setup.py index a1d4fdb53842..8449aeae7817 100644 --- a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/setup.py +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/setup.py @@ -81,8 +81,8 @@ ]), install_requires=[ 'msrest>=0.5.0', - 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', ], extras_require={ ":python_version<'3.0'": ['azure-mgmt-nspkg'],