Skip to content

Commit

Permalink
CodeGen from PR 18408 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
[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
Show file tree
Hide file tree
Showing 52 changed files with 3,380 additions and 183 deletions.
4 changes: 2 additions & 2 deletions sdk/resources/azure-mgmt-msi/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"@autorest/python@5.12.0",
"@autorest/modelerfour@4.19.3"
],
"commit": "f635d0ffb31308098993e02cc1ab1a83db6bb585",
"commit": "c52afb9c86f18f4f722e716c6a7ab4cabe337eb0",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"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/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2",
"autorest_command": "autorest specification/msi/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2",
"readme": "specification/msi/resource-manager/readme.md"
}
12 changes: 5 additions & 7 deletions sdk/resources/azure-mgmt-msi/azure/mgmt/msi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
# --------------------------------------------------------------------------

from ._managed_service_identity_client import ManagedServiceIdentityClient
from ._version import VERSION

__version__ = VERSION
__all__ = ['ManagedServiceIdentityClient']

# `._patch.py` is used for handwritten extensions to the generated code
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
from ._patch import patch_sdk
patch_sdk()
try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
27 changes: 15 additions & 12 deletions sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_configuration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# 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 Any, TYPE_CHECKING
from typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies
Expand All @@ -16,8 +18,9 @@

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
from typing import Any

from azure.core.credentials import TokenCredential

class ManagedServiceIdentityClientConfiguration(Configuration):
"""Configuration for ManagedServiceIdentityClient.
Expand All @@ -33,21 +36,21 @@ class ManagedServiceIdentityClientConfiguration(Configuration):

def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
**kwargs: Any
) -> None:
super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs)
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.")
super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs)

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

def _configure(
Expand Down
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)
5 changes: 0 additions & 5 deletions sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@

from ._managed_service_identity_client import ManagedServiceIdentityClient
__all__ = ['ManagedServiceIdentityClient']

# `._patch.py` is used for handwritten extensions to the generated code
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
from ._patch import patch_sdk
patch_sdk()
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# 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 Any, TYPE_CHECKING

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


class ManagedServiceIdentityClientConfiguration(Configuration):
"""Configuration for ManagedServiceIdentityClient.
Expand All @@ -35,19 +36,18 @@ def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
**kwargs: Any
**kwargs # type: Any
) -> None:
super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs)
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(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs)

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

def _configure(
Expand Down
Loading

0 comments on commit 22bd221

Please sign in to comment.