Skip to content

Commit eca57ae

Browse files
authored
[T2]hybridkubernetes (#15725)
1 parent fedc18d commit eca57ae

22 files changed

+2386
-969
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# Release History
22

3+
## 1.0.0b1 (2020-12-09)
4+
5+
This is beta preview version.
6+
7+
This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming).
8+
9+
**General breaking changes**
10+
11+
- Credential system has been completly revamped:
12+
13+
- `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/
14+
- `credentials` parameter has been renamed `credential`
15+
16+
- 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
17+
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)
18+
- You can't import a `version` module anymore, use `__version__` instead
19+
- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`.
20+
- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed).
21+
- Most of the operation kwarg have changed. Some of the most noticeable:
22+
23+
- `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user
24+
- For a complete set of
25+
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)
26+
27+
**General new features**
28+
29+
- Type annotations support using `typing`. SDKs are mypy ready.
30+
- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client.
31+
- 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.
32+
333
## 0.1.0 (2020-05-18)
434

535
* Initial Release

sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ This is the Microsoft Azure HybridKubernetes Management Client Library.
44
This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8.
55
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
66

7+
# Usage
8+
9+
10+
11+
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
12+
13+
14+
15+
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
16+
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.
17+
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
18+
19+
720
# Provide Feedback
821

922
If you encounter any bugs or have suggestions, please file an issue in the
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

12-
from ._configuration import ConnectedKubernetesClientConfiguration
139
from ._connected_kubernetes_client import ConnectedKubernetesClient
14-
__all__ = ['ConnectedKubernetesClient', 'ConnectedKubernetesClientConfiguration']
15-
16-
from .version import VERSION
10+
from ._version import VERSION
1711

1812
__version__ = VERSION
13+
__all__ = ['ConnectedKubernetesClient']
1914

15+
try:
16+
from ._patch import patch_sdk # type: ignore
17+
patch_sdk()
18+
except ImportError:
19+
pass
Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,71 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
11-
from msrestazure import AzureConfiguration
128

13-
from .version import VERSION
9+
from typing import TYPE_CHECKING
1410

11+
from azure.core.configuration import Configuration
12+
from azure.core.pipeline import policies
13+
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
14+
15+
from ._version import VERSION
16+
17+
if TYPE_CHECKING:
18+
# pylint: disable=unused-import,ungrouped-imports
19+
from typing import Any
20+
21+
from azure.core.credentials import TokenCredential
22+
23+
24+
class ConnectedKubernetesClientConfiguration(Configuration):
25+
"""Configuration for ConnectedKubernetesClient.
1526
16-
class ConnectedKubernetesClientConfiguration(AzureConfiguration):
17-
"""Configuration for ConnectedKubernetesClient
1827
Note that all parameters used to create this instance are saved as instance
1928
attributes.
2029
21-
:param credentials: Credentials needed for the client to connect to Azure.
22-
:type credentials: :mod:`A msrestazure Credentials
23-
object<msrestazure.azure_active_directory>`
30+
:param credential: Credential needed for the client to connect to Azure.
31+
:type credential: ~azure.core.credentials.TokenCredential
2432
:param subscription_id: The ID of the target subscription.
2533
:type subscription_id: str
26-
:param str base_url: Service URL
2734
"""
2835

2936
def __init__(
30-
self, credentials, subscription_id, base_url=None):
31-
32-
if credentials is None:
33-
raise ValueError("Parameter 'credentials' must not be None.")
37+
self,
38+
credential, # type: "TokenCredential"
39+
subscription_id, # type: str
40+
**kwargs # type: Any
41+
):
42+
# type: (...) -> None
43+
if credential is None:
44+
raise ValueError("Parameter 'credential' must not be None.")
3445
if subscription_id is None:
3546
raise ValueError("Parameter 'subscription_id' must not be None.")
36-
if not base_url:
37-
base_url = 'https://management.azure.com'
38-
39-
super(ConnectedKubernetesClientConfiguration, self).__init__(base_url)
40-
41-
# Starting Autorest.Python 4.0.64, make connection pool activated by default
42-
self.keep_alive = True
47+
super(ConnectedKubernetesClientConfiguration, self).__init__(**kwargs)
4348

44-
self.add_user_agent('azure-mgmt-hybridkubernetes/{}'.format(VERSION))
45-
self.add_user_agent('Azure-SDK-For-Python')
46-
47-
self.credentials = credentials
49+
self.credential = credential
4850
self.subscription_id = subscription_id
51+
self.api_version = "2020-01-01-preview"
52+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
53+
kwargs.setdefault('sdk_moniker', 'mgmt-hybridkubernetes/{}'.format(VERSION))
54+
self._configure(**kwargs)
55+
56+
def _configure(
57+
self,
58+
**kwargs # type: Any
59+
):
60+
# type: (...) -> None
61+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
62+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
63+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
64+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
65+
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
66+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
67+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
68+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
69+
self.authentication_policy = kwargs.get('authentication_policy')
70+
if self.credential and not self.authentication_policy:
71+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,75 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

12-
from msrest.service_client import SDKClient
13-
from msrest import Serializer, Deserializer
9+
from typing import TYPE_CHECKING
10+
11+
from azure.mgmt.core import ARMPipelineClient
12+
from msrest import Deserializer, Serializer
13+
14+
if TYPE_CHECKING:
15+
# pylint: disable=unused-import,ungrouped-imports
16+
from typing import Any, Optional
17+
18+
from azure.core.credentials import TokenCredential
1419

1520
from ._configuration import ConnectedKubernetesClientConfiguration
1621
from .operations import ConnectedClusterOperations
1722
from .operations import Operations
1823
from . import models
1924

2025

21-
class ConnectedKubernetesClient(SDKClient):
22-
"""Azure Connected Cluster Resource Provider API for adopting any Kubernetes Cluster
26+
class ConnectedKubernetesClient(object):
27+
"""Azure Connected Cluster Resource Provider API for adopting any Kubernetes Cluster.
2328
24-
:ivar config: Configuration for client.
25-
:vartype config: ConnectedKubernetesClientConfiguration
26-
27-
:ivar connected_cluster: ConnectedCluster operations
29+
:ivar connected_cluster: ConnectedClusterOperations operations
2830
:vartype connected_cluster: azure.mgmt.hybridkubernetes.operations.ConnectedClusterOperations
2931
:ivar operations: Operations operations
3032
:vartype operations: azure.mgmt.hybridkubernetes.operations.Operations
31-
32-
:param credentials: Credentials needed for the client to connect to Azure.
33-
:type credentials: :mod:`A msrestazure Credentials
34-
object<msrestazure.azure_active_directory>`
33+
:param credential: Credential needed for the client to connect to Azure.
34+
:type credential: ~azure.core.credentials.TokenCredential
3535
:param subscription_id: The ID of the target subscription.
3636
:type subscription_id: str
3737
:param str base_url: Service URL
38+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
3839
"""
3940

4041
def __init__(
41-
self, credentials, subscription_id, base_url=None):
42-
43-
self.config = ConnectedKubernetesClientConfiguration(credentials, subscription_id, base_url)
44-
super(ConnectedKubernetesClient, self).__init__(self.config.credentials, self.config)
42+
self,
43+
credential, # type: "TokenCredential"
44+
subscription_id, # type: str
45+
base_url=None, # type: Optional[str]
46+
**kwargs # type: Any
47+
):
48+
# type: (...) -> None
49+
if not base_url:
50+
base_url = 'https://management.azure.com'
51+
self._config = ConnectedKubernetesClientConfiguration(credential, subscription_id, **kwargs)
52+
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
4553

4654
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
47-
self.api_version = '2020-01-01-preview'
4855
self._serialize = Serializer(client_models)
56+
self._serialize.client_side_validation = False
4957
self._deserialize = Deserializer(client_models)
5058

5159
self.connected_cluster = ConnectedClusterOperations(
52-
self._client, self.config, self._serialize, self._deserialize)
60+
self._client, self._config, self._serialize, self._deserialize)
5361
self.operations = Operations(
54-
self._client, self.config, self._serialize, self._deserialize)
62+
self._client, self._config, self._serialize, self._deserialize)
63+
64+
def close(self):
65+
# type: () -> None
66+
self._client.close()
67+
68+
def __enter__(self):
69+
# type: () -> ConnectedKubernetesClient
70+
self._client.__enter__()
71+
return self
72+
73+
def __exit__(self, *exc_details):
74+
# type: (Any) -> None
75+
self._client.__exit__(*exc_details)
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

12-
VERSION = "0.1.0"
9+
VERSION = "1.0.0b1"
1310

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from ._connected_kubernetes_client import ConnectedKubernetesClient
10+
__all__ = ['ConnectedKubernetesClient']
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import Any, TYPE_CHECKING
10+
11+
from azure.core.configuration import Configuration
12+
from azure.core.pipeline import policies
13+
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
14+
15+
from .._version import VERSION
16+
17+
if TYPE_CHECKING:
18+
# pylint: disable=unused-import,ungrouped-imports
19+
from azure.core.credentials_async import AsyncTokenCredential
20+
21+
22+
class ConnectedKubernetesClientConfiguration(Configuration):
23+
"""Configuration for ConnectedKubernetesClient.
24+
25+
Note that all parameters used to create this instance are saved as instance
26+
attributes.
27+
28+
:param credential: Credential needed for the client to connect to Azure.
29+
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
30+
:param subscription_id: The ID of the target subscription.
31+
:type subscription_id: str
32+
"""
33+
34+
def __init__(
35+
self,
36+
credential: "AsyncTokenCredential",
37+
subscription_id: str,
38+
**kwargs: Any
39+
) -> None:
40+
if credential is None:
41+
raise ValueError("Parameter 'credential' must not be None.")
42+
if subscription_id is None:
43+
raise ValueError("Parameter 'subscription_id' must not be None.")
44+
super(ConnectedKubernetesClientConfiguration, self).__init__(**kwargs)
45+
46+
self.credential = credential
47+
self.subscription_id = subscription_id
48+
self.api_version = "2020-01-01-preview"
49+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
50+
kwargs.setdefault('sdk_moniker', 'mgmt-hybridkubernetes/{}'.format(VERSION))
51+
self._configure(**kwargs)
52+
53+
def _configure(
54+
self,
55+
**kwargs: Any
56+
) -> None:
57+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
58+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
59+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
60+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
61+
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
62+
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
63+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
64+
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
65+
self.authentication_policy = kwargs.get('authentication_policy')
66+
if self.credential and not self.authentication_policy:
67+
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)

0 commit comments

Comments
 (0)