forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CodeGen from PR 18408 in Azure/azure-rest-api-specs
[Msi] update readme.python to Multiapi (Azure#18408) * update readme.python to multiapi * Update readme.python.md * Update readme.python.md
- Loading branch information
SDKAuto
committed
Mar 28, 2022
1 parent
e24b848
commit 22bd221
Showing
52 changed files
with
3,380 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 115 additions & 58 deletions
173
sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_managed_service_identity_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,155 @@ | ||
# 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 copy import deepcopy | ||
from typing import Any, Optional, TYPE_CHECKING | ||
from typing import TYPE_CHECKING | ||
|
||
from azure.core.rest import HttpRequest, HttpResponse | ||
from azure.mgmt.core import ARMPipelineClient | ||
from azure.profiles import KnownProfiles, ProfileDefinition | ||
from azure.profiles.multiapiclient import MultiApiClientMixin | ||
from msrest import Deserializer, Serializer | ||
|
||
from . import models | ||
from ._configuration import ManagedServiceIdentityClientConfiguration | ||
from .operations import Operations, SystemAssignedIdentitiesOperations, UserAssignedIdentitiesOperations | ||
|
||
if TYPE_CHECKING: | ||
# pylint: disable=unused-import,ungrouped-imports | ||
from typing import Any, Optional | ||
|
||
from azure.core.credentials import TokenCredential | ||
|
||
class ManagedServiceIdentityClient: | ||
class _SDKClient(object): | ||
def __init__(self, *args, **kwargs): | ||
"""This is a fake class to support current implemetation of MultiApiClientMixin." | ||
Will be removed in final version of multiapi azure-core based client | ||
""" | ||
pass | ||
|
||
class ManagedServiceIdentityClient(MultiApiClientMixin, _SDKClient): | ||
"""The Managed Service Identity Client. | ||
:ivar system_assigned_identities: SystemAssignedIdentitiesOperations operations | ||
:vartype system_assigned_identities: | ||
azure.mgmt.msi.operations.SystemAssignedIdentitiesOperations | ||
:ivar operations: Operations operations | ||
:vartype operations: azure.mgmt.msi.operations.Operations | ||
:ivar user_assigned_identities: UserAssignedIdentitiesOperations operations | ||
:vartype user_assigned_identities: azure.mgmt.msi.operations.UserAssignedIdentitiesOperations | ||
This ready contains multiple API versions, to help you deal with all of the Azure clouds | ||
(Azure Stack, Azure Government, Azure China, etc.). | ||
By default, it uses the latest API version available on public Azure. | ||
For production, you should stick to a particular api-version and/or profile. | ||
The profile sets a mapping between an operation group and its API version. | ||
The api-version parameter sets the default API version if the operation | ||
group is not described in the profile. | ||
:param credential: Credential needed for the client to connect to Azure. | ||
:type credential: ~azure.core.credentials.TokenCredential | ||
:param subscription_id: The Id of the Subscription to which the identity belongs. | ||
:type subscription_id: str | ||
:param base_url: Service URL. Default value is 'https://management.azure.com'. | ||
:param api_version: API version to use if no profile is provided, or if missing in profile. | ||
:type api_version: str | ||
:param base_url: Service URL | ||
:type base_url: str | ||
:param profile: A profile definition, from KnownProfiles to dict. | ||
:type profile: azure.profiles.KnownProfiles | ||
""" | ||
|
||
DEFAULT_API_VERSION = '2018-11-30' | ||
_PROFILE_TAG = "azure.mgmt.msi.ManagedServiceIdentityClient" | ||
LATEST_PROFILE = ProfileDefinition({ | ||
_PROFILE_TAG: { | ||
None: DEFAULT_API_VERSION, | ||
}}, | ||
_PROFILE_TAG + " latest" | ||
) | ||
|
||
def __init__( | ||
self, | ||
credential: "TokenCredential", | ||
subscription_id: str, | ||
base_url: str = "https://management.azure.com", | ||
**kwargs: Any | ||
) -> None: | ||
self._config = ManagedServiceIdentityClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) | ||
credential, # type: "TokenCredential" | ||
subscription_id, # type: str | ||
api_version=None, # type: Optional[str] | ||
base_url="https://management.azure.com", # type: str | ||
profile=KnownProfiles.default, # type: KnownProfiles | ||
**kwargs # type: Any | ||
): | ||
self._config = ManagedServiceIdentityClientConfiguration(credential, subscription_id, **kwargs) | ||
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) | ||
super(ManagedServiceIdentityClient, self).__init__( | ||
api_version=api_version, | ||
profile=profile | ||
) | ||
|
||
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} | ||
self._serialize = Serializer(client_models) | ||
self._deserialize = Deserializer(client_models) | ||
self._serialize.client_side_validation = False | ||
self.system_assigned_identities = SystemAssignedIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) | ||
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) | ||
self.user_assigned_identities = UserAssignedIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) | ||
@classmethod | ||
def _models_dict(cls, api_version): | ||
return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} | ||
|
||
@classmethod | ||
def models(cls, api_version=DEFAULT_API_VERSION): | ||
"""Module depends on the API version: | ||
def _send_request( | ||
self, | ||
request, # type: HttpRequest | ||
**kwargs: Any | ||
) -> HttpResponse: | ||
"""Runs the network request through the client's chained policies. | ||
>>> from azure.core.rest import HttpRequest | ||
>>> request = HttpRequest("GET", "https://www.example.org/") | ||
<HttpRequest [GET], url: 'https://www.example.org/'> | ||
>>> response = client._send_request(request) | ||
<HttpResponse: 200 OK> | ||
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart | ||
:param request: The network request you want to make. Required. | ||
:type request: ~azure.core.rest.HttpRequest | ||
:keyword bool stream: Whether the response payload will be streamed. Defaults to False. | ||
:return: The response of your network call. Does not do error handling on your response. | ||
:rtype: ~azure.core.rest.HttpResponse | ||
* 2018-11-30: :mod:`v2018_11_30.models<azure.mgmt.msi.v2018_11_30.models>` | ||
* 2021-09-30-preview: :mod:`v2019_09_01_preview.models<azure.mgmt.msi.v2019_09_01_preview.models>` | ||
""" | ||
|
||
request_copy = deepcopy(request) | ||
request_copy.url = self._client.format_url(request_copy.url) | ||
return self._client.send_request(request_copy, **kwargs) | ||
if api_version == '2018-11-30': | ||
from .v2018_11_30 import models | ||
return models | ||
elif api_version == '2021-09-30-preview': | ||
from .v2019_09_01_preview import models | ||
return models | ||
raise ValueError("API version {} is not available".format(api_version)) | ||
|
||
@property | ||
def operations(self): | ||
"""Instance depends on the API version: | ||
* 2018-11-30: :class:`Operations<azure.mgmt.msi.v2018_11_30.operations.Operations>` | ||
* 2021-09-30-preview: :class:`Operations<azure.mgmt.msi.v2019_09_01_preview.operations.Operations>` | ||
""" | ||
api_version = self._get_api_version('operations') | ||
if api_version == '2018-11-30': | ||
from .v2018_11_30.operations import Operations as OperationClass | ||
elif api_version == '2021-09-30-preview': | ||
from .v2019_09_01_preview.operations import Operations as OperationClass | ||
else: | ||
raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) | ||
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) | ||
|
||
@property | ||
def system_assigned_identities(self): | ||
"""Instance depends on the API version: | ||
* 2018-11-30: :class:`SystemAssignedIdentitiesOperations<azure.mgmt.msi.v2018_11_30.operations.SystemAssignedIdentitiesOperations>` | ||
* 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations<azure.mgmt.msi.v2019_09_01_preview.operations.SystemAssignedIdentitiesOperations>` | ||
""" | ||
api_version = self._get_api_version('system_assigned_identities') | ||
if api_version == '2018-11-30': | ||
from .v2018_11_30.operations import SystemAssignedIdentitiesOperations as OperationClass | ||
elif api_version == '2021-09-30-preview': | ||
from .v2019_09_01_preview.operations import SystemAssignedIdentitiesOperations as OperationClass | ||
else: | ||
raise ValueError("API version {} does not have operation group 'system_assigned_identities'".format(api_version)) | ||
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) | ||
|
||
@property | ||
def user_assigned_identities(self): | ||
"""Instance depends on the API version: | ||
* 2018-11-30: :class:`UserAssignedIdentitiesOperations<azure.mgmt.msi.v2018_11_30.operations.UserAssignedIdentitiesOperations>` | ||
* 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations<azure.mgmt.msi.v2019_09_01_preview.operations.UserAssignedIdentitiesOperations>` | ||
""" | ||
api_version = self._get_api_version('user_assigned_identities') | ||
if api_version == '2018-11-30': | ||
from .v2018_11_30.operations import UserAssignedIdentitiesOperations as OperationClass | ||
elif api_version == '2021-09-30-preview': | ||
from .v2019_09_01_preview.operations import UserAssignedIdentitiesOperations as OperationClass | ||
else: | ||
raise ValueError("API version {} does not have operation group 'user_assigned_identities'".format(api_version)) | ||
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) | ||
|
||
def close(self): | ||
# type: () -> None | ||
self._client.close() | ||
|
||
def __enter__(self): | ||
# type: () -> ManagedServiceIdentityClient | ||
self._client.__enter__() | ||
return self | ||
|
||
def __exit__(self, *exc_details): | ||
# type: (Any) -> None | ||
self._client.__exit__(*exc_details) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.