Skip to content

Commit 8fdb885

Browse files
azclibotBigCat20196msyyc
authored
[AutoRelease] t2-msi-2022-03-29-51948(Do not merge) (Azure#23719)
* code and test * update version * Update CHANGELOG.md Co-authored-by: PythonSdkPipelines <PythonSdkPipelines> Co-authored-by: Jiefeng Chen (WICRESOFT NORTH AMERICA LTD) <[email protected]> Co-authored-by: Yuchao Yan <[email protected]>
1 parent 4831051 commit 8fdb885

Some content is hidden

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

54 files changed

+3388
-184
lines changed

sdk/resources/azure-mgmt-msi/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Release History
22

3+
## 6.0.0 (2022-03-29)
4+
5+
**Breaking changes**
6+
7+
- Change from single-api package to multiple-api package which permits users to pass in different api version in client.
8+
9+
310
## 6.0.0b2 (2022-03-24)
411

512
**Features**

sdk/resources/azure-mgmt-msi/_meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"@autorest/[email protected]",
55
"@autorest/[email protected]"
66
],
7-
"commit": "f635d0ffb31308098993e02cc1ab1a83db6bb585",
7+
"commit": "3026119ab41bbce77275cfa3a1afbabf43af5aea",
88
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
9-
"autorest_command": "autorest specification/msi/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.7.2",
9+
"autorest_command": "autorest specification/msi/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.7.2",
1010
"readme": "specification/msi/resource-manager/readme.md"
1111
}

sdk/resources/azure-mgmt-msi/azure/mgmt/msi/__init__.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
# --------------------------------------------------------------------------
88

99
from ._managed_service_identity_client import ManagedServiceIdentityClient
10-
from ._version import VERSION
11-
12-
__version__ = VERSION
1310
__all__ = ['ManagedServiceIdentityClient']
1411

15-
# `._patch.py` is used for handwritten extensions to the generated code
16-
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
17-
from ._patch import patch_sdk
18-
patch_sdk()
12+
try:
13+
from ._patch import patch_sdk # type: ignore
14+
patch_sdk()
15+
except ImportError:
16+
pass

sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_configuration.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
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 license information.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
57
# Code generated by Microsoft (R) AutoRest Code Generator.
6-
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
710
# --------------------------------------------------------------------------
8-
9-
from typing import Any, TYPE_CHECKING
11+
from typing import TYPE_CHECKING
1012

1113
from azure.core.configuration import Configuration
1214
from azure.core.pipeline import policies
@@ -16,8 +18,9 @@
1618

1719
if TYPE_CHECKING:
1820
# pylint: disable=unused-import,ungrouped-imports
19-
from azure.core.credentials import TokenCredential
21+
from typing import Any
2022

23+
from azure.core.credentials import TokenCredential
2124

2225
class ManagedServiceIdentityClientConfiguration(Configuration):
2326
"""Configuration for ManagedServiceIdentityClient.
@@ -33,21 +36,21 @@ class ManagedServiceIdentityClientConfiguration(Configuration):
3336

3437
def __init__(
3538
self,
36-
credential: "TokenCredential",
37-
subscription_id: str,
38-
**kwargs: Any
39-
) -> None:
40-
super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs)
39+
credential, # type: "TokenCredential"
40+
subscription_id, # type: str
41+
**kwargs # type: Any
42+
):
43+
# type: (...) -> None
4144
if credential is None:
4245
raise ValueError("Parameter 'credential' must not be None.")
4346
if subscription_id is None:
4447
raise ValueError("Parameter 'subscription_id' must not be None.")
48+
super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs)
4549

4650
self.credential = credential
4751
self.subscription_id = subscription_id
48-
self.api_version = "2021-09-30-preview"
4952
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
50-
kwargs.setdefault('sdk_moniker', 'mgmt-msi/{}'.format(VERSION))
53+
kwargs.setdefault('sdk_moniker', 'azure-mgmt-msi/{}'.format(VERSION))
5154
self._configure(**kwargs)
5255

5356
def _configure(
Lines changed: 115 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,155 @@
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 license information.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
57
# Code generated by Microsoft (R) AutoRest Code Generator.
6-
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
710
# --------------------------------------------------------------------------
811

9-
from copy import deepcopy
10-
from typing import Any, Optional, TYPE_CHECKING
12+
from typing import TYPE_CHECKING
1113

12-
from azure.core.rest import HttpRequest, HttpResponse
1314
from azure.mgmt.core import ARMPipelineClient
15+
from azure.profiles import KnownProfiles, ProfileDefinition
16+
from azure.profiles.multiapiclient import MultiApiClientMixin
1417
from msrest import Deserializer, Serializer
1518

16-
from . import models
1719
from ._configuration import ManagedServiceIdentityClientConfiguration
18-
from .operations import Operations, SystemAssignedIdentitiesOperations, UserAssignedIdentitiesOperations
1920

2021
if TYPE_CHECKING:
2122
# pylint: disable=unused-import,ungrouped-imports
23+
from typing import Any, Optional
24+
2225
from azure.core.credentials import TokenCredential
2326

24-
class ManagedServiceIdentityClient:
27+
class _SDKClient(object):
28+
def __init__(self, *args, **kwargs):
29+
"""This is a fake class to support current implemetation of MultiApiClientMixin."
30+
Will be removed in final version of multiapi azure-core based client
31+
"""
32+
pass
33+
34+
class ManagedServiceIdentityClient(MultiApiClientMixin, _SDKClient):
2535
"""The Managed Service Identity Client.
2636
27-
:ivar system_assigned_identities: SystemAssignedIdentitiesOperations operations
28-
:vartype system_assigned_identities:
29-
azure.mgmt.msi.operations.SystemAssignedIdentitiesOperations
30-
:ivar operations: Operations operations
31-
:vartype operations: azure.mgmt.msi.operations.Operations
32-
:ivar user_assigned_identities: UserAssignedIdentitiesOperations operations
33-
:vartype user_assigned_identities: azure.mgmt.msi.operations.UserAssignedIdentitiesOperations
37+
This ready contains multiple API versions, to help you deal with all of the Azure clouds
38+
(Azure Stack, Azure Government, Azure China, etc.).
39+
By default, it uses the latest API version available on public Azure.
40+
For production, you should stick to a particular api-version and/or profile.
41+
The profile sets a mapping between an operation group and its API version.
42+
The api-version parameter sets the default API version if the operation
43+
group is not described in the profile.
44+
3445
:param credential: Credential needed for the client to connect to Azure.
3546
:type credential: ~azure.core.credentials.TokenCredential
3647
:param subscription_id: The Id of the Subscription to which the identity belongs.
3748
:type subscription_id: str
38-
:param base_url: Service URL. Default value is 'https://management.azure.com'.
49+
:param api_version: API version to use if no profile is provided, or if missing in profile.
50+
:type api_version: str
51+
:param base_url: Service URL
3952
:type base_url: str
53+
:param profile: A profile definition, from KnownProfiles to dict.
54+
:type profile: azure.profiles.KnownProfiles
4055
"""
4156

57+
DEFAULT_API_VERSION = '2018-11-30'
58+
_PROFILE_TAG = "azure.mgmt.msi.ManagedServiceIdentityClient"
59+
LATEST_PROFILE = ProfileDefinition({
60+
_PROFILE_TAG: {
61+
None: DEFAULT_API_VERSION,
62+
}},
63+
_PROFILE_TAG + " latest"
64+
)
65+
4266
def __init__(
4367
self,
44-
credential: "TokenCredential",
45-
subscription_id: str,
46-
base_url: str = "https://management.azure.com",
47-
**kwargs: Any
48-
) -> None:
49-
self._config = ManagedServiceIdentityClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs)
68+
credential, # type: "TokenCredential"
69+
subscription_id, # type: str
70+
api_version=None, # type: Optional[str]
71+
base_url="https://management.azure.com", # type: str
72+
profile=KnownProfiles.default, # type: KnownProfiles
73+
**kwargs # type: Any
74+
):
75+
self._config = ManagedServiceIdentityClientConfiguration(credential, subscription_id, **kwargs)
5076
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
77+
super(ManagedServiceIdentityClient, self).__init__(
78+
api_version=api_version,
79+
profile=profile
80+
)
5181

52-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
53-
self._serialize = Serializer(client_models)
54-
self._deserialize = Deserializer(client_models)
55-
self._serialize.client_side_validation = False
56-
self.system_assigned_identities = SystemAssignedIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize)
57-
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
58-
self.user_assigned_identities = UserAssignedIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize)
82+
@classmethod
83+
def _models_dict(cls, api_version):
84+
return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}
5985

86+
@classmethod
87+
def models(cls, api_version=DEFAULT_API_VERSION):
88+
"""Module depends on the API version:
6089
61-
def _send_request(
62-
self,
63-
request, # type: HttpRequest
64-
**kwargs: Any
65-
) -> HttpResponse:
66-
"""Runs the network request through the client's chained policies.
67-
68-
>>> from azure.core.rest import HttpRequest
69-
>>> request = HttpRequest("GET", "https://www.example.org/")
70-
<HttpRequest [GET], url: 'https://www.example.org/'>
71-
>>> response = client._send_request(request)
72-
<HttpResponse: 200 OK>
73-
74-
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
75-
76-
:param request: The network request you want to make. Required.
77-
:type request: ~azure.core.rest.HttpRequest
78-
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
79-
:return: The response of your network call. Does not do error handling on your response.
80-
:rtype: ~azure.core.rest.HttpResponse
90+
* 2018-11-30: :mod:`v2018_11_30.models<azure.mgmt.msi.v2018_11_30.models>`
91+
* 2021-09-30-preview: :mod:`v2019_09_01_preview.models<azure.mgmt.msi.v2019_09_01_preview.models>`
8192
"""
82-
83-
request_copy = deepcopy(request)
84-
request_copy.url = self._client.format_url(request_copy.url)
85-
return self._client.send_request(request_copy, **kwargs)
93+
if api_version == '2018-11-30':
94+
from .v2018_11_30 import models
95+
return models
96+
elif api_version == '2021-09-30-preview':
97+
from .v2019_09_01_preview import models
98+
return models
99+
raise ValueError("API version {} is not available".format(api_version))
100+
101+
@property
102+
def operations(self):
103+
"""Instance depends on the API version:
104+
105+
* 2018-11-30: :class:`Operations<azure.mgmt.msi.v2018_11_30.operations.Operations>`
106+
* 2021-09-30-preview: :class:`Operations<azure.mgmt.msi.v2019_09_01_preview.operations.Operations>`
107+
"""
108+
api_version = self._get_api_version('operations')
109+
if api_version == '2018-11-30':
110+
from .v2018_11_30.operations import Operations as OperationClass
111+
elif api_version == '2021-09-30-preview':
112+
from .v2019_09_01_preview.operations import Operations as OperationClass
113+
else:
114+
raise ValueError("API version {} does not have operation group 'operations'".format(api_version))
115+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
116+
117+
@property
118+
def system_assigned_identities(self):
119+
"""Instance depends on the API version:
120+
121+
* 2018-11-30: :class:`SystemAssignedIdentitiesOperations<azure.mgmt.msi.v2018_11_30.operations.SystemAssignedIdentitiesOperations>`
122+
* 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations<azure.mgmt.msi.v2019_09_01_preview.operations.SystemAssignedIdentitiesOperations>`
123+
"""
124+
api_version = self._get_api_version('system_assigned_identities')
125+
if api_version == '2018-11-30':
126+
from .v2018_11_30.operations import SystemAssignedIdentitiesOperations as OperationClass
127+
elif api_version == '2021-09-30-preview':
128+
from .v2019_09_01_preview.operations import SystemAssignedIdentitiesOperations as OperationClass
129+
else:
130+
raise ValueError("API version {} does not have operation group 'system_assigned_identities'".format(api_version))
131+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
132+
133+
@property
134+
def user_assigned_identities(self):
135+
"""Instance depends on the API version:
136+
137+
* 2018-11-30: :class:`UserAssignedIdentitiesOperations<azure.mgmt.msi.v2018_11_30.operations.UserAssignedIdentitiesOperations>`
138+
* 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations<azure.mgmt.msi.v2019_09_01_preview.operations.UserAssignedIdentitiesOperations>`
139+
"""
140+
api_version = self._get_api_version('user_assigned_identities')
141+
if api_version == '2018-11-30':
142+
from .v2018_11_30.operations import UserAssignedIdentitiesOperations as OperationClass
143+
elif api_version == '2021-09-30-preview':
144+
from .v2019_09_01_preview.operations import UserAssignedIdentitiesOperations as OperationClass
145+
else:
146+
raise ValueError("API version {} does not have operation group 'user_assigned_identities'".format(api_version))
147+
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
86148

87149
def close(self):
88-
# type: () -> None
89150
self._client.close()
90-
91151
def __enter__(self):
92-
# type: () -> ManagedServiceIdentityClient
93152
self._client.__enter__()
94153
return self
95-
96154
def __exit__(self, *exc_details):
97-
# type: (Any) -> None
98155
self._client.__exit__(*exc_details)

sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "6.0.0b2"
9+
VERSION = "6.0.0"

sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,3 @@
88

99
from ._managed_service_identity_client import ManagedServiceIdentityClient
1010
__all__ = ['ManagedServiceIdentityClient']
11-
12-
# `._patch.py` is used for handwritten extensions to the generated code
13-
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
14-
from ._patch import patch_sdk
15-
patch_sdk()

sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_configuration.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
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 license information.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
57
# Code generated by Microsoft (R) AutoRest Code Generator.
6-
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
710
# --------------------------------------------------------------------------
8-
911
from typing import Any, TYPE_CHECKING
1012

1113
from azure.core.configuration import Configuration
@@ -18,7 +20,6 @@
1820
# pylint: disable=unused-import,ungrouped-imports
1921
from azure.core.credentials_async import AsyncTokenCredential
2022

21-
2223
class ManagedServiceIdentityClientConfiguration(Configuration):
2324
"""Configuration for ManagedServiceIdentityClient.
2425
@@ -35,19 +36,18 @@ def __init__(
3536
self,
3637
credential: "AsyncTokenCredential",
3738
subscription_id: str,
38-
**kwargs: Any
39+
**kwargs # type: Any
3940
) -> None:
40-
super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs)
4141
if credential is None:
4242
raise ValueError("Parameter 'credential' must not be None.")
4343
if subscription_id is None:
4444
raise ValueError("Parameter 'subscription_id' must not be None.")
45+
super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs)
4546

4647
self.credential = credential
4748
self.subscription_id = subscription_id
48-
self.api_version = "2021-09-30-preview"
4949
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
50-
kwargs.setdefault('sdk_moniker', 'mgmt-msi/{}'.format(VERSION))
50+
kwargs.setdefault('sdk_moniker', 'azure-mgmt-msi/{}'.format(VERSION))
5151
self._configure(**kwargs)
5252

5353
def _configure(

0 commit comments

Comments
 (0)