Skip to content

Commit 78eb1b3

Browse files
msyycSDKAuto
andauthored
[T2] digitaltwins 2021 01 07 (Azure#16013)
* CodeGen from PR 12150 in Azure/azure-rest-api-specs python track2 configure (Azure#12150) * test,version,CHANGELOG * readme.md * Update README.md * delete surplus _verison.py Co-authored-by: SDKAuto <sdkautomation@microsoft.com>
1 parent 9fb2f34 commit 78eb1b3

File tree

81 files changed

+15407
-1679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+15407
-1679
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# Release History
22

3+
## 6.0.0b1 (2021-01-07)
4+
5+
This is beta preview version.
6+
For detailed changelog please refer to equivalent stable version 1.0.0(https://pypi.org/project/azure-mgmt-digitaltwins/1.0.0/)
7+
8+
This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming).
9+
10+
**General breaking changes**
11+
12+
- Credential system has been completly revamped:
13+
14+
- `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/
15+
- `credentials` parameter has been renamed `credential`
16+
17+
- 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
18+
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)
19+
- You can't import a `version` module anymore, use `__version__` instead
20+
- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`.
21+
- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed).
22+
- Most of the operation kwarg have changed. Some of the most noticeable:
23+
24+
- `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user
25+
- 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)
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+
33+
## 1.0.0 (2020-09-24)
34+
35+
* Release as Multi-API package.
36+
337
## 0.1.0 (2020-05-31)
438

539
* Initial Release

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# Microsoft Azure SDK for Python
22

3-
This is the Microsoft Azure DigitalTwins Management Client Library.
3+
This is the Microsoft Azure Digitaltwins 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

77

88
# Usage
99

10-
For code examples, see [DigitalTwins Management](https://docs.microsoft.com/python/api/overview/azure/)
11-
on docs.microsoft.com.
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 [Digitaltwins 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)
1218

1319

1420
# Provide Feedback
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
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 AzureDigitalTwinsManagementClientConfiguration
139
from ._azure_digital_twins_management_client import AzureDigitalTwinsManagementClient
14-
__all__ = ['AzureDigitalTwinsManagementClient', 'AzureDigitalTwinsManagementClientConfiguration']
15-
16-
from .version import VERSION
17-
18-
__version__ = VERSION
10+
__all__ = ['AzureDigitalTwinsManagementClient']
1911

12+
try:
13+
from ._patch import patch_sdk # type: ignore
14+
patch_sdk()
15+
except ImportError:
16+
pass

sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_azure_digital_twins_management_client.py

Lines changed: 164 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,180 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
from msrest.service_client import SDKClient
12+
from azure.mgmt.core import ARMPipelineClient
1313
from msrest import Serializer, Deserializer
1414

15+
from azure.profiles import KnownProfiles, ProfileDefinition
16+
from azure.profiles.multiapiclient import MultiApiClientMixin
1517
from ._configuration import AzureDigitalTwinsManagementClientConfiguration
16-
from .operations import DigitalTwinsOperations
17-
from .operations import DigitalTwinsEndpointOperations
18-
from .operations import Operations
19-
from . import models
2018

19+
class _SDKClient(object):
20+
def __init__(self, *args, **kwargs):
21+
"""This is a fake class to support current implemetation of MultiApiClientMixin."
22+
Will be removed in final version of multiapi azure-core based client
23+
"""
24+
pass
2125

22-
class AzureDigitalTwinsManagementClient(SDKClient):
23-
"""Azure Digital Twins Client for managing DigitalTwinsInstance
26+
class AzureDigitalTwinsManagementClient(MultiApiClientMixin, _SDKClient):
27+
"""Azure Digital Twins Client for managing DigitalTwinsInstance.
2428
25-
:ivar config: Configuration for client.
26-
:vartype config: AzureDigitalTwinsManagementClientConfiguration
29+
This ready contains multiple API versions, to help you deal with all of the Azure clouds
30+
(Azure Stack, Azure Government, Azure China, etc.).
31+
By default, it uses the latest API version available on public Azure.
32+
For production, you should stick to a particular api-version and/or profile.
33+
The profile sets a mapping between an operation group and its API version.
34+
The api-version parameter sets the default API version if the operation
35+
group is not described in the profile.
2736
28-
:ivar digital_twins: DigitalTwins operations
29-
:vartype digital_twins: azure.mgmt.digitaltwins.operations.DigitalTwinsOperations
30-
:ivar digital_twins_endpoint: DigitalTwinsEndpoint operations
31-
:vartype digital_twins_endpoint: azure.mgmt.digitaltwins.operations.DigitalTwinsEndpointOperations
32-
:ivar operations: Operations operations
33-
:vartype operations: azure.mgmt.digitaltwins.operations.Operations
34-
35-
:param credentials: Credentials needed for the client to connect to Azure.
36-
:type credentials: :mod:`A msrestazure Credentials
37-
object<msrestazure.azure_active_directory>`
37+
:param credential: Credential needed for the client to connect to Azure.
38+
:type credential: ~azure.core.credentials.TokenCredential
3839
:param subscription_id: The subscription identifier.
3940
:type subscription_id: str
41+
:param str api_version: API version to use if no profile is provided, or if
42+
missing in profile.
4043
:param str base_url: Service URL
44+
:param profile: A profile definition, from KnownProfiles to dict.
45+
:type profile: azure.profiles.KnownProfiles
46+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
4147
"""
4248

49+
DEFAULT_API_VERSION = '2020-12-01'
50+
_PROFILE_TAG = "azure.mgmt.digitaltwins.AzureDigitalTwinsManagementClient"
51+
LATEST_PROFILE = ProfileDefinition({
52+
_PROFILE_TAG: {
53+
None: DEFAULT_API_VERSION,
54+
}},
55+
_PROFILE_TAG + " latest"
56+
)
57+
4358
def __init__(
44-
self, credentials, subscription_id, base_url=None):
45-
46-
self.config = AzureDigitalTwinsManagementClientConfiguration(credentials, subscription_id, base_url)
47-
super(AzureDigitalTwinsManagementClient, self).__init__(self.config.credentials, self.config)
48-
49-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
50-
self.api_version = '2020-03-01-preview'
51-
self._serialize = Serializer(client_models)
52-
self._deserialize = Deserializer(client_models)
53-
54-
self.digital_twins = DigitalTwinsOperations(
55-
self._client, self.config, self._serialize, self._deserialize)
56-
self.digital_twins_endpoint = DigitalTwinsEndpointOperations(
57-
self._client, self.config, self._serialize, self._deserialize)
58-
self.operations = Operations(
59-
self._client, self.config, self._serialize, self._deserialize)
59+
self,
60+
credential, # type: "TokenCredential"
61+
subscription_id, # type: str
62+
api_version=None,
63+
base_url=None,
64+
profile=KnownProfiles.default,
65+
**kwargs # type: Any
66+
):
67+
if not base_url:
68+
base_url = 'https://management.azure.com'
69+
self._config = AzureDigitalTwinsManagementClientConfiguration(credential, subscription_id, **kwargs)
70+
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
71+
super(AzureDigitalTwinsManagementClient, self).__init__(
72+
api_version=api_version,
73+
profile=profile
74+
)
75+
76+
@classmethod
77+
def _models_dict(cls, api_version):
78+
return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}
79+
80+
@classmethod
81+
def models(cls, api_version=DEFAULT_API_VERSION):
82+
"""Module depends on the API version:
83+
84+
* 2020-03-01-preview: :mod:`v2020_03_01_preview.models<azure.mgmt.digitaltwins.v2020_03_01_preview.models>`
85+
* 2020-10-31: :mod:`v2020_10_31.models<azure.mgmt.digitaltwins.v2020_10_31.models>`
86+
* 2020-12-01: :mod:`v2020_12_01.models<azure.mgmt.digitaltwins.v2020_12_01.models>`
87+
"""
88+
if api_version == '2020-03-01-preview':
89+
from .v2020_03_01_preview import models
90+
return models
91+
elif api_version == '2020-10-31':
92+
from .v2020_10_31 import models
93+
return models
94+
elif api_version == '2020-12-01':
95+
from .v2020_12_01 import models
96+
return models
97+
raise ValueError("API version {} is not available".format(api_version))
98+
99+
@property
100+
def digital_twins(self):
101+
"""Instance depends on the API version:
102+
103+
* 2020-03-01-preview: :class:`DigitalTwinsOperations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.DigitalTwinsOperations>`
104+
* 2020-10-31: :class:`DigitalTwinsOperations<azure.mgmt.digitaltwins.v2020_10_31.operations.DigitalTwinsOperations>`
105+
* 2020-12-01: :class:`DigitalTwinsOperations<azure.mgmt.digitaltwins.v2020_12_01.operations.DigitalTwinsOperations>`
106+
"""
107+
api_version = self._get_api_version('digital_twins')
108+
if api_version == '2020-03-01-preview':
109+
from .v2020_03_01_preview.operations import DigitalTwinsOperations as OperationClass
110+
elif api_version == '2020-10-31':
111+
from .v2020_10_31.operations import DigitalTwinsOperations as OperationClass
112+
elif api_version == '2020-12-01':
113+
from .v2020_12_01.operations import DigitalTwinsOperations as OperationClass
114+
else:
115+
raise ValueError("API version {} does not have operation group 'digital_twins'".format(api_version))
116+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
117+
118+
@property
119+
def digital_twins_endpoint(self):
120+
"""Instance depends on the API version:
121+
122+
* 2020-03-01-preview: :class:`DigitalTwinsEndpointOperations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.DigitalTwinsEndpointOperations>`
123+
* 2020-10-31: :class:`DigitalTwinsEndpointOperations<azure.mgmt.digitaltwins.v2020_10_31.operations.DigitalTwinsEndpointOperations>`
124+
* 2020-12-01: :class:`DigitalTwinsEndpointOperations<azure.mgmt.digitaltwins.v2020_12_01.operations.DigitalTwinsEndpointOperations>`
125+
"""
126+
api_version = self._get_api_version('digital_twins_endpoint')
127+
if api_version == '2020-03-01-preview':
128+
from .v2020_03_01_preview.operations import DigitalTwinsEndpointOperations as OperationClass
129+
elif api_version == '2020-10-31':
130+
from .v2020_10_31.operations import DigitalTwinsEndpointOperations as OperationClass
131+
elif api_version == '2020-12-01':
132+
from .v2020_12_01.operations import DigitalTwinsEndpointOperations as OperationClass
133+
else:
134+
raise ValueError("API version {} does not have operation group 'digital_twins_endpoint'".format(api_version))
135+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
136+
137+
@property
138+
def operations(self):
139+
"""Instance depends on the API version:
140+
141+
* 2020-03-01-preview: :class:`Operations<azure.mgmt.digitaltwins.v2020_03_01_preview.operations.Operations>`
142+
* 2020-10-31: :class:`Operations<azure.mgmt.digitaltwins.v2020_10_31.operations.Operations>`
143+
* 2020-12-01: :class:`Operations<azure.mgmt.digitaltwins.v2020_12_01.operations.Operations>`
144+
"""
145+
api_version = self._get_api_version('operations')
146+
if api_version == '2020-03-01-preview':
147+
from .v2020_03_01_preview.operations import Operations as OperationClass
148+
elif api_version == '2020-10-31':
149+
from .v2020_10_31.operations import Operations as OperationClass
150+
elif api_version == '2020-12-01':
151+
from .v2020_12_01.operations import Operations as OperationClass
152+
else:
153+
raise ValueError("API version {} does not have operation group 'operations'".format(api_version))
154+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
155+
156+
@property
157+
def private_endpoint_connections(self):
158+
"""Instance depends on the API version:
159+
160+
* 2020-12-01: :class:`PrivateEndpointConnectionsOperations<azure.mgmt.digitaltwins.v2020_12_01.operations.PrivateEndpointConnectionsOperations>`
161+
"""
162+
api_version = self._get_api_version('private_endpoint_connections')
163+
if api_version == '2020-12-01':
164+
from .v2020_12_01.operations import PrivateEndpointConnectionsOperations as OperationClass
165+
else:
166+
raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version))
167+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
168+
169+
@property
170+
def private_link_resources(self):
171+
"""Instance depends on the API version:
172+
173+
* 2020-12-01: :class:`PrivateLinkResourcesOperations<azure.mgmt.digitaltwins.v2020_12_01.operations.PrivateLinkResourcesOperations>`
174+
"""
175+
api_version = self._get_api_version('private_link_resources')
176+
if api_version == '2020-12-01':
177+
from .v2020_12_01.operations import PrivateLinkResourcesOperations as OperationClass
178+
else:
179+
raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version))
180+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
181+
182+
def close(self):
183+
self._client.close()
184+
def __enter__(self):
185+
self._client.__enter__()
186+
return self
187+
def __exit__(self, *exc_details):
188+
self._client.__exit__(*exc_details)

sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_configuration.py

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,59 @@
88
# Changes may cause incorrect behavior and will be lost if the code is
99
# regenerated.
1010
# --------------------------------------------------------------------------
11-
from msrestazure import AzureConfiguration
11+
from typing import Any
1212

13-
from .version import VERSION
13+
from azure.core.configuration import Configuration
14+
from azure.core.pipeline import policies
15+
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
1416

17+
from ._version import VERSION
18+
19+
20+
class AzureDigitalTwinsManagementClientConfiguration(Configuration):
21+
"""Configuration for AzureDigitalTwinsManagementClient.
1522
16-
class AzureDigitalTwinsManagementClientConfiguration(AzureConfiguration):
17-
"""Configuration for AzureDigitalTwinsManagementClient
1823
Note that all parameters used to create this instance are saved as instance
1924
attributes.
2025
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>`
26+
:param credential: Credential needed for the client to connect to Azure.
27+
:type credential: ~azure.core.credentials.TokenCredential
2428
:param subscription_id: The subscription identifier.
2529
:type subscription_id: str
26-
:param str base_url: Service URL
2730
"""
2831

2932
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.")
33+
self,
34+
credential, # type: "TokenCredential"
35+
subscription_id, # type: str
36+
**kwargs # type: Any
37+
):
38+
# type: (...) -> None
39+
if credential is None:
40+
raise ValueError("Parameter 'credential' must not be None.")
3441
if subscription_id is None:
3542
raise ValueError("Parameter 'subscription_id' must not be None.")
36-
if not base_url:
37-
base_url = 'https://management.azure.com'
38-
39-
super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(base_url)
43+
super(AzureDigitalTwinsManagementClientConfiguration, self).__init__(**kwargs)
4044

41-
# Starting Autorest.Python 4.0.64, make connection pool activated by default
42-
self.keep_alive = True
43-
44-
self.add_user_agent('azure-mgmt-digitaltwins/{}'.format(VERSION))
45-
self.add_user_agent('Azure-SDK-For-Python')
46-
47-
self.credentials = credentials
45+
self.credential = credential
4846
self.subscription_id = subscription_id
47+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
48+
kwargs.setdefault('sdk_moniker', 'azure-mgmt-digitaltwins/{}'.format(VERSION))
49+
self._configure(**kwargs)
50+
51+
def _configure(
52+
self,
53+
**kwargs # type: Any
54+
):
55+
# type: (...) -> None
56+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
57+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
58+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
59+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
60+
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
61+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
62+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
63+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
64+
self.authentication_policy = kwargs.get('authentication_policy')
65+
if self.credential and not self.authentication_policy:
66+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)

sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/version.py renamed to sdk/digitaltwins/azure-mgmt-digitaltwins/azure/mgmt/digitaltwins/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
VERSION = "0.1.0"
12+
VERSION = "6.0.0b1"
1313

0 commit comments

Comments
 (0)