From b907f32eb66027301020e738ca4433c7f14a80be Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 25 Mar 2022 05:56:42 +0000 Subject: [PATCH] CodeGen from PR 18408 in Azure/azure-rest-api-specs Merge c5d6d631c52d7605ce25a5383c513597dc535d80 into 61218420e95ad3435a029144877b110b56418958 --- sdk/resources/azure-mgmt-msi/_meta.json | 4 +- .../azure-mgmt-msi/azure/mgmt/msi/__init__.py | 12 +- .../azure/mgmt/msi/_configuration.py | 27 +- .../msi/_managed_service_identity_client.py | 173 +++-- .../azure/mgmt/msi/aio/__init__.py | 5 - .../azure/mgmt/msi/aio/_configuration.py | 16 +- .../aio/_managed_service_identity_client.py | 170 +++-- .../azure-mgmt-msi/azure/mgmt/msi/models.py | 7 + .../azure/mgmt/msi/v2018_11_30/__init__.py | 18 + .../mgmt/msi/v2018_11_30/_configuration.py | 68 ++ .../_managed_service_identity_client.py | 99 +++ .../azure/mgmt/msi/v2018_11_30/_metadata.json | 104 +++ .../mgmt/msi/{aio => v2018_11_30}/_patch.py | 0 .../mgmt/msi/{ => v2018_11_30}/_vendor.py | 0 .../azure/mgmt/msi/v2018_11_30/_version.py | 9 + .../mgmt/msi/v2018_11_30/aio/__init__.py | 15 + .../msi/v2018_11_30/aio/_configuration.py | 67 ++ .../aio/_managed_service_identity_client.py | 96 +++ .../azure/mgmt/msi/v2018_11_30/aio/_patch.py | 31 + .../aio/operations/__init__.py | 0 .../aio/operations/_operations.py | 5 +- .../_system_assigned_identities_operations.py | 4 +- .../_user_assigned_identities_operations.py | 402 +++++++++++ .../mgmt/msi/v2018_11_30/models/__init__.py | 34 + .../msi/v2018_11_30/models/_models_py3.py | 548 +++++++++++++++ .../{ => v2018_11_30}/operations/__init__.py | 0 .../msi/v2018_11_30/operations/_operations.py | 134 ++++ .../_system_assigned_identities_operations.py | 125 ++++ .../_user_assigned_identities_operations.py | 626 ++++++++++++++++++ .../azure/mgmt/msi/v2018_11_30/py.typed | 1 + .../mgmt/msi/v2019_09_01_preview/__init__.py | 18 + .../msi/v2019_09_01_preview/_configuration.py | 68 ++ .../_managed_service_identity_client.py | 99 +++ .../{ => v2019_09_01_preview}/_metadata.json | 0 .../mgmt/msi/v2019_09_01_preview/_patch.py | 31 + .../mgmt/msi/v2019_09_01_preview/_vendor.py | 27 + .../mgmt/msi/v2019_09_01_preview/_version.py | 9 + .../msi/v2019_09_01_preview/aio/__init__.py | 15 + .../v2019_09_01_preview/aio/_configuration.py | 67 ++ .../aio/_managed_service_identity_client.py | 96 +++ .../msi/v2019_09_01_preview/aio/_patch.py | 31 + .../aio/operations/__init__.py | 17 + .../aio/operations/_operations.py | 109 +++ .../_system_assigned_identities_operations.py | 92 +++ .../_user_assigned_identities_operations.py | 18 +- .../models/__init__.py | 0 .../models/_models_py3.py | 18 +- .../operations/__init__.py | 17 + .../operations/_operations.py | 5 +- .../_system_assigned_identities_operations.py | 4 +- .../_user_assigned_identities_operations.py | 21 +- .../mgmt/msi/v2019_09_01_preview/py.typed | 1 + 52 files changed, 3380 insertions(+), 183 deletions(-) create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/__init__.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_configuration.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_managed_service_identity_client.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_metadata.json rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{aio => v2018_11_30}/_patch.py (100%) rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2018_11_30}/_vendor.py (100%) create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_version.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_configuration.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_managed_service_identity_client.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_patch.py rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2018_11_30}/aio/operations/__init__.py (100%) rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2018_11_30}/aio/operations/_operations.py (96%) rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2018_11_30}/aio/operations/_system_assigned_identities_operations.py (96%) create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_user_assigned_identities_operations.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/__init__.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/_models_py3.py rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2018_11_30}/operations/__init__.py (100%) create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_operations.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_system_assigned_identities_operations.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_user_assigned_identities_operations.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/py.typed create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/__init__.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_configuration.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_managed_service_identity_client.py rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2019_09_01_preview}/_metadata.json (100%) create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_patch.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_vendor.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_version.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_configuration.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_managed_service_identity_client.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/__init__.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_operations.py create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_system_assigned_identities_operations.py rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2019_09_01_preview}/aio/operations/_user_assigned_identities_operations.py (97%) rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2019_09_01_preview}/models/__init__.py (100%) rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2019_09_01_preview}/models/_models_py3.py (96%) create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/__init__.py rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2019_09_01_preview}/operations/_operations.py (96%) rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2019_09_01_preview}/operations/_system_assigned_identities_operations.py (97%) rename sdk/resources/azure-mgmt-msi/azure/mgmt/msi/{ => v2019_09_01_preview}/operations/_user_assigned_identities_operations.py (97%) create mode 100644 sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/py.typed diff --git a/sdk/resources/azure-mgmt-msi/_meta.json b/sdk/resources/azure-mgmt-msi/_meta.json index 009969fff933..3578583fb6bd 100644 --- a/sdk/resources/azure-mgmt-msi/_meta.json +++ b/sdk/resources/azure-mgmt-msi/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@5.12.0", "@autorest/modelerfour@4.19.3" ], - "commit": "f635d0ffb31308098993e02cc1ab1a83db6bb585", + "commit": "1bd51b71c4eb1066309b59915156696e1c6f1ce5", "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-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/msi/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/__init__.py index 2768cf132e10..3804c4fd0ece 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/__init__.py @@ -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 diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_configuration.py index c3bab8b89071..d6db63a35415 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_configuration.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_configuration.py @@ -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 @@ -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. @@ -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( diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_managed_service_identity_client.py index 878fa3fdaf4a..381aee6af425 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_managed_service_identity_client.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_managed_service_identity_client.py @@ -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/") - - >>> response = client._send_request(request) - - - 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` + * 2021-09-30-preview: :mod:`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` + * 2021-09-30-preview: :class:`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` + * 2021-09-30-preview: :class:`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` + * 2021-09-30-preview: :class:`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) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/__init__.py index 7bda71f08efd..e3d506433190 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/__init__.py @@ -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() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_configuration.py index 791c398d9fad..50387fd70a17 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_configuration.py @@ -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 @@ -18,7 +20,6 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential - class ManagedServiceIdentityClientConfiguration(Configuration): """Configuration for ManagedServiceIdentityClient. @@ -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( diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_managed_service_identity_client.py index de703ea7b7d4..ff9f157bbc78 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_managed_service_identity_client.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_managed_service_identity_client.py @@ -1,96 +1,154 @@ # 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, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING -from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +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 azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential -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.aio.operations.SystemAssignedIdentitiesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.msi.aio.operations.Operations - :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations - :vartype user_assigned_identities: - azure.mgmt.msi.aio.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_async.AsyncTokenCredential :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: "AsyncTokenCredential", subscription_id: str, + api_version: Optional[str] = None, base_url: str = "https://management.azure.com", - **kwargs: Any + profile: KnownProfiles = KnownProfiles.default, + **kwargs # type: Any ) -> None: - self._config = ManagedServiceIdentityClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ManagedServiceIdentityClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(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: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - 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.AsyncHttpResponse + * 2018-11-30: :mod:`v2018_11_30.models` + * 2021-09-30-preview: :mod:`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) - - async def close(self) -> None: + 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` + * 2021-09-30-preview: :class:`Operations` + """ + api_version = self._get_api_version('operations') + if api_version == '2018-11-30': + from ..v2018_11_30.aio.operations import Operations as OperationClass + elif api_version == '2021-09-30-preview': + from ..v2019_09_01_preview.aio.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` + * 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations` + """ + api_version = self._get_api_version('system_assigned_identities') + if api_version == '2018-11-30': + from ..v2018_11_30.aio.operations import SystemAssignedIdentitiesOperations as OperationClass + elif api_version == '2021-09-30-preview': + from ..v2019_09_01_preview.aio.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` + * 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations` + """ + api_version = self._get_api_version('user_assigned_identities') + if api_version == '2018-11-30': + from ..v2018_11_30.aio.operations import UserAssignedIdentitiesOperations as OperationClass + elif api_version == '2021-09-30-preview': + from ..v2019_09_01_preview.aio.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))) + + async def close(self): await self._client.close() - - async def __aenter__(self) -> "ManagedServiceIdentityClient": + async def __aenter__(self): await self._client.__aenter__() return self - - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details): await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models.py new file mode 100644 index 000000000000..fc753f02ed9d --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------- +from .v2018_11_30.models import * diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/__init__.py new file mode 100644 index 000000000000..2768cf132e10 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/__init__.py @@ -0,0 +1,18 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_configuration.py new file mode 100644 index 000000000000..d5f791ffbae5 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_configuration.py @@ -0,0 +1,68 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# 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 +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ManagedServiceIdentityClientConfiguration(Configuration): + """Configuration for ManagedServiceIdentityClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: 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.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2018-11-30" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-msi/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_managed_service_identity_client.py new file mode 100644 index 000000000000..2b8363f8e28d --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_managed_service_identity_client.py @@ -0,0 +1,99 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# 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 azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +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 azure.core.credentials import TokenCredential + +class ManagedServiceIdentityClient: + """The Managed Service Identity Client. + + :ivar system_assigned_identities: SystemAssignedIdentitiesOperations operations + :vartype system_assigned_identities: + azure.mgmt.msi.v2018_11_30.operations.SystemAssignedIdentitiesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.msi.v2018_11_30.operations.Operations + :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations + :vartype user_assigned_identities: + azure.mgmt.msi.v2018_11_30.operations.UserAssignedIdentitiesOperations + :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'. + :type base_url: str + """ + + 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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + 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) + + + 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/") + + >>> response = client._send_request(request) + + + 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 + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + 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) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_metadata.json b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_metadata.json new file mode 100644 index 000000000000..2afb48779cf2 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_metadata.json @@ -0,0 +1,104 @@ +{ + "chosen_version": "2018-11-30", + "total_api_version_list": ["2018-11-30"], + "client": { + "name": "ManagedServiceIdentityClient", + "filename": "_managed_service_identity_client", + "description": "The Managed Service Identity Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagedServiceIdentityClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagedServiceIdentityClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The Id of the Subscription to which the identity belongs.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The Id of the Subscription to which the identity belongs.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "system_assigned_identities": "SystemAssignedIdentitiesOperations", + "operations": "Operations", + "user_assigned_identities": "UserAssignedIdentitiesOperations" + } +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_patch.py similarity index 100% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/_patch.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_patch.py diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_vendor.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_vendor.py similarity index 100% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_vendor.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_vendor.py diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_version.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_version.py @@ -0,0 +1,9 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/__init__.py new file mode 100644 index 000000000000..7bda71f08efd --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/__init__.py @@ -0,0 +1,15 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_configuration.py new file mode 100644 index 000000000000..c303ee873d5b --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# 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 +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ManagedServiceIdentityClientConfiguration(Configuration): + """Configuration for ManagedServiceIdentityClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Id of the Subscription to which the identity belongs. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: 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.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2018-11-30" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-msi/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_managed_service_identity_client.py new file mode 100644 index 000000000000..00eb93bc39c9 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_managed_service_identity_client.py @@ -0,0 +1,96 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +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 azure.core.credentials_async import AsyncTokenCredential + +class ManagedServiceIdentityClient: + """The Managed Service Identity Client. + + :ivar system_assigned_identities: SystemAssignedIdentitiesOperations operations + :vartype system_assigned_identities: + azure.mgmt.msi.v2018_11_30.aio.operations.SystemAssignedIdentitiesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.msi.v2018_11_30.aio.operations.Operations + :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations + :vartype user_assigned_identities: + azure.mgmt.msi.v2018_11_30.aio.operations.UserAssignedIdentitiesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :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'. + :type base_url: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ManagedServiceIdentityClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + 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) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + 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.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ManagedServiceIdentityClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file 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 +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/__init__.py similarity index 100% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/__init__.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/__init__.py diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_operations.py similarity index 96% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_operations.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_operations.py index 5633c4cf3140..df52901f6b37 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_operations.py @@ -31,7 +31,7 @@ class Operations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.models + :type models: ~azure.mgmt.msi.v2018_11_30.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -55,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2018_11_30.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_system_assigned_identities_operations.py similarity index 96% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_system_assigned_identities_operations.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_system_assigned_identities_operations.py index ef84410926b3..28eda463f6d1 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_system_assigned_identities_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_system_assigned_identities_operations.py @@ -29,7 +29,7 @@ class SystemAssignedIdentitiesOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.models + :type models: ~azure.mgmt.msi.v2018_11_30.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -57,7 +57,7 @@ async def get_by_scope( :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SystemAssignedIdentity, or the result of cls(response) - :rtype: ~azure.mgmt.msi.models.SystemAssignedIdentity + :rtype: ~azure.mgmt.msi.v2018_11_30.models.SystemAssignedIdentity :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemAssignedIdentity"] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_user_assigned_identities_operations.py new file mode 100644 index 000000000000..150dab25730b --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_user_assigned_identities_operations.py @@ -0,0 +1,402 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._user_assigned_identities_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class UserAssignedIdentitiesOperations: + """UserAssignedIdentitiesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.v2018_11_30.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.UserAssignedIdentitiesListResult"]: + """Lists all the userAssignedIdentities available under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2018_11_30.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UserAssignedIdentitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.UserAssignedIdentitiesListResult"]: + """Lists all the userAssignedIdentities available under the specified ResourceGroup. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2018_11_30.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UserAssignedIdentitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities'} # type: ignore + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: "_models.Identity", + **kwargs: Any + ) -> "_models.Identity": + """Create or update an identity in the specified subscription and resource group. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :param resource_name: The name of the identity resource. + :type resource_name: str + :param parameters: Parameters to create or update the identity. + :type parameters: ~azure.mgmt.msi.v2018_11_30.models.Identity + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Identity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2018_11_30.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Identity') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Identity', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Identity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + parameters: "_models.IdentityUpdate", + **kwargs: Any + ) -> "_models.Identity": + """Update an identity in the specified subscription and resource group. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :param resource_name: The name of the identity resource. + :type resource_name: str + :param parameters: Parameters to update the identity. + :type parameters: ~azure.mgmt.msi.v2018_11_30.models.IdentityUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Identity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2018_11_30.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IdentityUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Identity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.Identity": + """Gets the identity. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :param resource_name: The name of the identity resource. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Identity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2018_11_30.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Identity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: + """Deletes the identity. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :param resource_name: The name of the identity resource. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/__init__.py new file mode 100644 index 000000000000..37575c0dfb74 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/__init__.py @@ -0,0 +1,34 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import CloudErrorBody +from ._models_py3 import Identity +from ._models_py3 import IdentityUpdate +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import SystemAssignedIdentity +from ._models_py3 import TrackedResource +from ._models_py3 import UserAssignedIdentitiesListResult + + +__all__ = [ + 'CloudErrorBody', + 'Identity', + 'IdentityUpdate', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'SystemAssignedIdentity', + 'TrackedResource', + 'UserAssignedIdentitiesListResult', +] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/_models_py3.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/_models_py3.py new file mode 100644 index 000000000000..0c07408ffaa4 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/_models_py3.py @@ -0,0 +1,548 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional + +import msrest.serialization + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the ManagedServiceIdentity service. + + :ivar code: An identifier for the error. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.msi.v2018_11_30.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.msi.v2018_11_30.models.CloudErrorBody] + """ + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class Identity(TrackedResource): + """Describes an identity resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tenant_id: The id of the tenant which the identity belongs to. + :vartype tenant_id: str + :ivar principal_id: The id of the service principal object associated with the created + identity. + :vartype principal_id: str + :ivar client_id: The id of the app associated with the identity. This is a random generated + UUID by MSI. + :vartype client_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'tenant_id': {'readonly': True}, + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'client_id': {'key': 'properties.clientId', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ + super(Identity, self).__init__(tags=tags, location=location, **kwargs) + self.tenant_id = None + self.principal_id = None + self.client_id = None + + +class IdentityUpdate(Resource): + """Describes an identity resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar tenant_id: The id of the tenant which the identity belongs to. + :vartype tenant_id: str + :ivar principal_id: The id of the service principal object associated with the created + identity. + :vartype principal_id: str + :ivar client_id: The id of the app associated with the identity. This is a random generated + UUID by MSI. + :vartype client_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'client_id': {'key': 'properties.clientId', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(IdentityUpdate, self).__init__(**kwargs) + self.location = location + self.tags = tags + self.tenant_id = None + self.principal_id = None + self.client_id = None + + +class Operation(msrest.serialization.Model): + """Operation supported by the Microsoft.ManagedIdentity REST API. + + :ivar name: The name of the REST Operation. This is of the format + {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that describes the operation. + :vartype display: ~azure.mgmt.msi.v2018_11_30.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + """ + :keyword name: The name of the REST Operation. This is of the format + {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that describes the operation. + :paramtype display: ~azure.mgmt.msi.v2018_11_30.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """The object that describes the operation. + + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + :ivar operation: The type of operation. For example: read, write, delete. + :vartype operation: str + :ivar resource: The resource type on which the operation is performed. + :vartype resource: str + :ivar description: A description of the operation. + :vartype description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + operation: Optional[str] = None, + resource: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Friendly name of the resource provider. + :paramtype provider: str + :keyword operation: The type of operation. For example: read, write, delete. + :paramtype operation: str + :keyword resource: The resource type on which the operation is performed. + :paramtype resource: str + :keyword description: A description of the operation. + :paramtype description: str + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.operation = operation + self.resource = resource + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """A list of operations supported by Microsoft.ManagedIdentity Resource Provider. + + :ivar value: A list of operations supported by Microsoft.ManagedIdentity Resource Provider. + :vartype value: list[~azure.mgmt.msi.v2018_11_30.models.Operation] + :ivar next_link: The url to get the next page of results, if any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: A list of operations supported by Microsoft.ManagedIdentity Resource Provider. + :paramtype value: list[~azure.mgmt.msi.v2018_11_30.models.Operation] + :keyword next_link: The url to get the next page of results, if any. + :paramtype next_link: str + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class SystemAssignedIdentity(ProxyResource): + """Describes a system assigned identity resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar tenant_id: The id of the tenant which the identity belongs to. + :vartype tenant_id: str + :ivar principal_id: The id of the service principal object associated with the created + identity. + :vartype principal_id: str + :ivar client_id: The id of the app associated with the identity. This is a random generated + UUID by MSI. + :vartype client_id: str + :ivar client_secret_url: The ManagedServiceIdentity DataPlane URL that can be queried to obtain + the identity credentials. + :vartype client_secret_url: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'tenant_id': {'readonly': True}, + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + 'client_secret_url': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'client_id': {'key': 'properties.clientId', 'type': 'str'}, + 'client_secret_url': {'key': 'properties.clientSecretUrl', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(SystemAssignedIdentity, self).__init__(**kwargs) + self.location = location + self.tags = tags + self.tenant_id = None + self.principal_id = None + self.client_id = None + self.client_secret_url = None + + +class UserAssignedIdentitiesListResult(msrest.serialization.Model): + """Values returned by the List operation. + + :ivar value: The collection of userAssignedIdentities returned by the listing operation. + :vartype value: list[~azure.mgmt.msi.v2018_11_30.models.Identity] + :ivar next_link: The url to get the next page of results, if any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Identity]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Identity"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The collection of userAssignedIdentities returned by the listing operation. + :paramtype value: list[~azure.mgmt.msi.v2018_11_30.models.Identity] + :keyword next_link: The url to get the next page of results, if any. + :paramtype next_link: str + """ + super(UserAssignedIdentitiesListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/__init__.py similarity index 100% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/__init__.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/__init__.py diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_operations.py new file mode 100644 index 000000000000..62c8e77bdfce --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_operations.py @@ -0,0 +1,134 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagedIdentity/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.v2018_11_30.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """Lists available operations for the Microsoft.ManagedIdentity provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2018_11_30.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.ManagedIdentity/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_system_assigned_identities_operations.py new file mode 100644 index 000000000000..b3a8f5e4f8b7 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_system_assigned_identities_operations.py @@ -0,0 +1,125 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_by_scope_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedIdentity/identities/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class SystemAssignedIdentitiesOperations(object): + """SystemAssignedIdentitiesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.v2018_11_30.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get_by_scope( + self, + scope: str, + **kwargs: Any + ) -> "_models.SystemAssignedIdentity": + """Gets the systemAssignedIdentity available under the specified RP scope. + + :param scope: The resource provider scope of the resource. Parent resource being extended by + Managed Identities. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SystemAssignedIdentity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2018_11_30.models.SystemAssignedIdentity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemAssignedIdentity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_scope_request( + scope=scope, + template_url=self.get_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SystemAssignedIdentity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.ManagedIdentity/identities/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_user_assigned_identities_operations.py new file mode 100644 index 000000000000..853b34e439a0 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_user_assigned_identities_operations.py @@ -0,0 +1,626 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-11-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-11-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class UserAssignedIdentitiesOperations(object): + """UserAssignedIdentitiesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.v2018_11_30.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.UserAssignedIdentitiesListResult"]: + """Lists all the userAssignedIdentities available under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2018_11_30.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UserAssignedIdentitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.UserAssignedIdentitiesListResult"]: + """Lists all the userAssignedIdentities available under the specified ResourceGroup. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2018_11_30.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UserAssignedIdentitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities'} # type: ignore + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: "_models.Identity", + **kwargs: Any + ) -> "_models.Identity": + """Create or update an identity in the specified subscription and resource group. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :param resource_name: The name of the identity resource. + :type resource_name: str + :param parameters: Parameters to create or update the identity. + :type parameters: ~azure.mgmt.msi.v2018_11_30.models.Identity + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Identity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2018_11_30.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Identity') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Identity', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Identity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + parameters: "_models.IdentityUpdate", + **kwargs: Any + ) -> "_models.Identity": + """Update an identity in the specified subscription and resource group. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :param resource_name: The name of the identity resource. + :type resource_name: str + :param parameters: Parameters to update the identity. + :type parameters: ~azure.mgmt.msi.v2018_11_30.models.IdentityUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Identity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2018_11_30.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IdentityUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Identity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.Identity": + """Gets the identity. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :param resource_name: The name of the identity resource. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Identity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2018_11_30.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Identity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: + """Deletes the identity. + + :param resource_group_name: The name of the Resource Group to which the identity belongs. + :type resource_group_name: str + :param resource_name: The name of the identity resource. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/py.typed b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/__init__.py new file mode 100644 index 000000000000..2768cf132e10 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/__init__.py @@ -0,0 +1,18 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_configuration.py new file mode 100644 index 000000000000..c3bab8b89071 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_configuration.py @@ -0,0 +1,68 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# 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 +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ManagedServiceIdentityClientConfiguration(Configuration): + """Configuration for ManagedServiceIdentityClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: 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.") + + 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)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_managed_service_identity_client.py new file mode 100644 index 000000000000..2c3279938ef8 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_managed_service_identity_client.py @@ -0,0 +1,99 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# 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 azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +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 azure.core.credentials import TokenCredential + +class ManagedServiceIdentityClient: + """The Managed Service Identity Client. + + :ivar system_assigned_identities: SystemAssignedIdentitiesOperations operations + :vartype system_assigned_identities: + azure.mgmt.msi.v2019_09_01_preview.operations.SystemAssignedIdentitiesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.msi.v2019_09_01_preview.operations.Operations + :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations + :vartype user_assigned_identities: + azure.mgmt.msi.v2019_09_01_preview.operations.UserAssignedIdentitiesOperations + :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'. + :type base_url: str + """ + + 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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + 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) + + + 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/") + + >>> response = client._send_request(request) + + + 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 + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + 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) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_metadata.json b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_metadata.json similarity index 100% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_metadata.json rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_metadata.json diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file 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 +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_vendor.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# 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. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_version.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/_version.py @@ -0,0 +1,9 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/__init__.py new file mode 100644 index 000000000000..7bda71f08efd --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/__init__.py @@ -0,0 +1,15 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..791c398d9fad --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# 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 +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ManagedServiceIdentityClientConfiguration(Configuration): + """Configuration for ManagedServiceIdentityClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Id of the Subscription to which the identity belongs. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: 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.") + + 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)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_managed_service_identity_client.py new file mode 100644 index 000000000000..f8a681e0d857 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_managed_service_identity_client.py @@ -0,0 +1,96 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +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 azure.core.credentials_async import AsyncTokenCredential + +class ManagedServiceIdentityClient: + """The Managed Service Identity Client. + + :ivar system_assigned_identities: SystemAssignedIdentitiesOperations operations + :vartype system_assigned_identities: + azure.mgmt.msi.v2019_09_01_preview.aio.operations.SystemAssignedIdentitiesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.msi.v2019_09_01_preview.aio.operations.Operations + :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations + :vartype user_assigned_identities: + azure.mgmt.msi.v2019_09_01_preview.aio.operations.UserAssignedIdentitiesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :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'. + :type base_url: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ManagedServiceIdentityClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + 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) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + 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.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ManagedServiceIdentityClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file 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 +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..3b14b3b27ba4 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/__init__.py @@ -0,0 +1,17 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._system_assigned_identities_operations import SystemAssignedIdentitiesOperations +from ._operations import Operations +from ._user_assigned_identities_operations import UserAssignedIdentitiesOperations + +__all__ = [ + 'SystemAssignedIdentitiesOperations', + 'Operations', + 'UserAssignedIdentitiesOperations', +] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..c41ac52cbb87 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_operations.py @@ -0,0 +1,109 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.v2019_09_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists available operations for the Microsoft.ManagedIdentity provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2019_09_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.ManagedIdentity/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_system_assigned_identities_operations.py new file mode 100644 index 000000000000..1411eb5825b5 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_system_assigned_identities_operations.py @@ -0,0 +1,92 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._system_assigned_identities_operations import build_get_by_scope_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SystemAssignedIdentitiesOperations: + """SystemAssignedIdentitiesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.v2019_09_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get_by_scope( + self, + scope: str, + **kwargs: Any + ) -> "_models.SystemAssignedIdentity": + """Gets the systemAssignedIdentity available under the specified RP scope. + + :param scope: The resource provider scope of the resource. Parent resource being extended by + Managed Identities. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SystemAssignedIdentity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2019_09_01_preview.models.SystemAssignedIdentity + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemAssignedIdentity"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_scope_request( + scope=scope, + template_url=self.get_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SystemAssignedIdentity', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.ManagedIdentity/identities/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_user_assigned_identities_operations.py similarity index 97% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_user_assigned_identities_operations.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_user_assigned_identities_operations.py index 6a28b9259f15..6c7d1acde5ce 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/aio/operations/_user_assigned_identities_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/operations/_user_assigned_identities_operations.py @@ -31,7 +31,7 @@ class UserAssignedIdentitiesOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.models + :type models: ~azure.mgmt.msi.v2019_09_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -57,7 +57,7 @@ def list_by_subscription( :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.models.UserAssignedIdentitiesListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2019_09_01_preview.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] @@ -125,7 +125,7 @@ def list_by_resource_group( :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.models.UserAssignedIdentitiesListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2019_09_01_preview.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] @@ -216,7 +216,7 @@ def list_associated_resources( :return: An iterator like instance of either AssociatedResourcesListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.models.AssociatedResourcesListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2019_09_01_preview.models.AssociatedResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AssociatedResourcesListResult"] @@ -299,10 +299,10 @@ async def create_or_update( :param resource_name: The name of the identity resource. :type resource_name: str :param parameters: Parameters to create or update the identity. - :type parameters: ~azure.mgmt.msi.models.Identity + :type parameters: ~azure.mgmt.msi.v2019_09_01_preview.models.Identity :keyword callable cls: A custom type or function that will be passed the direct response :return: Identity, or the result of cls(response) - :rtype: ~azure.mgmt.msi.models.Identity + :rtype: ~azure.mgmt.msi.v2019_09_01_preview.models.Identity :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] @@ -362,10 +362,10 @@ async def update( :param resource_name: The name of the identity resource. :type resource_name: str :param parameters: Parameters to update the identity. - :type parameters: ~azure.mgmt.msi.models.IdentityUpdate + :type parameters: ~azure.mgmt.msi.v2019_09_01_preview.models.IdentityUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: Identity, or the result of cls(response) - :rtype: ~azure.mgmt.msi.models.Identity + :rtype: ~azure.mgmt.msi.v2019_09_01_preview.models.Identity :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] @@ -421,7 +421,7 @@ async def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Identity, or the result of cls(response) - :rtype: ~azure.mgmt.msi.models.Identity + :rtype: ~azure.mgmt.msi.v2019_09_01_preview.models.Identity :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/models/__init__.py similarity index 100% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models/__init__.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/models/__init__.py diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models/_models_py3.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/models/_models_py3.py similarity index 96% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models/_models_py3.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/models/_models_py3.py index 45c2c5823a39..33ec753b0c4a 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/models/_models_py3.py @@ -20,7 +20,7 @@ class AssociatedResourcesListResult(msrest.serialization.Model): :vartype total_count: float :ivar value: The collection of Azure resources returned by the resource action to get a list of assigned resources. - :vartype value: list[~azure.mgmt.msi.models.AzureResource] + :vartype value: list[~azure.mgmt.msi.v2019_09_01_preview.models.AzureResource] :ivar next_link: The url to get the next page of results, if any. :vartype next_link: str """ @@ -113,7 +113,7 @@ class CloudErrorBody(msrest.serialization.Model): error. :vartype target: str :ivar details: A list of additional details about the error. - :vartype details: list[~azure.mgmt.msi.models.CloudErrorBody] + :vartype details: list[~azure.mgmt.msi.v2019_09_01_preview.models.CloudErrorBody] """ _attribute_map = { @@ -142,7 +142,7 @@ def __init__( error. :paramtype target: str :keyword details: A list of additional details about the error. - :paramtype details: list[~azure.mgmt.msi.models.CloudErrorBody] + :paramtype details: list[~azure.mgmt.msi.v2019_09_01_preview.models.CloudErrorBody] """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code @@ -388,7 +388,7 @@ class Operation(msrest.serialization.Model): {provider}/{resource}/{operation}. :vartype name: str :ivar display: The object that describes the operation. - :vartype display: ~azure.mgmt.msi.models.OperationDisplay + :vartype display: ~azure.mgmt.msi.v2019_09_01_preview.models.OperationDisplay """ _attribute_map = { @@ -408,7 +408,7 @@ def __init__( {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that describes the operation. - :paramtype display: ~azure.mgmt.msi.models.OperationDisplay + :paramtype display: ~azure.mgmt.msi.v2019_09_01_preview.models.OperationDisplay """ super(Operation, self).__init__(**kwargs) self.name = name @@ -465,7 +465,7 @@ class OperationListResult(msrest.serialization.Model): """A list of operations supported by Microsoft.ManagedIdentity Resource Provider. :ivar value: A list of operations supported by Microsoft.ManagedIdentity Resource Provider. - :vartype value: list[~azure.mgmt.msi.models.Operation] + :vartype value: list[~azure.mgmt.msi.v2019_09_01_preview.models.Operation] :ivar next_link: The url to get the next page of results, if any. :vartype next_link: str """ @@ -484,7 +484,7 @@ def __init__( ): """ :keyword value: A list of operations supported by Microsoft.ManagedIdentity Resource Provider. - :paramtype value: list[~azure.mgmt.msi.models.Operation] + :paramtype value: list[~azure.mgmt.msi.v2019_09_01_preview.models.Operation] :keyword next_link: The url to get the next page of results, if any. :paramtype next_link: str """ @@ -610,7 +610,7 @@ class UserAssignedIdentitiesListResult(msrest.serialization.Model): """Values returned by the List operation. :ivar value: The collection of userAssignedIdentities returned by the listing operation. - :vartype value: list[~azure.mgmt.msi.models.Identity] + :vartype value: list[~azure.mgmt.msi.v2019_09_01_preview.models.Identity] :ivar next_link: The url to get the next page of results, if any. :vartype next_link: str """ @@ -629,7 +629,7 @@ def __init__( ): """ :keyword value: The collection of userAssignedIdentities returned by the listing operation. - :paramtype value: list[~azure.mgmt.msi.models.Identity] + :paramtype value: list[~azure.mgmt.msi.v2019_09_01_preview.models.Identity] :keyword next_link: The url to get the next page of results, if any. :paramtype next_link: str """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/__init__.py new file mode 100644 index 000000000000..3b14b3b27ba4 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/__init__.py @@ -0,0 +1,17 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._system_assigned_identities_operations import SystemAssignedIdentitiesOperations +from ._operations import Operations +from ._user_assigned_identities_operations import UserAssignedIdentitiesOperations + +__all__ = [ + 'SystemAssignedIdentitiesOperations', + 'Operations', + 'UserAssignedIdentitiesOperations', +] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_operations.py similarity index 96% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_operations.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_operations.py index d35745c52089..7490f9642e78 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_operations.py @@ -57,7 +57,7 @@ class Operations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.models + :type models: ~azure.mgmt.msi.v2019_09_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -81,7 +81,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.msi.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2019_09_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_system_assigned_identities_operations.py similarity index 97% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_system_assigned_identities_operations.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_system_assigned_identities_operations.py index 4f8e42f787c6..8582c6d619d8 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_system_assigned_identities_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_system_assigned_identities_operations.py @@ -62,7 +62,7 @@ class SystemAssignedIdentitiesOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.models + :type models: ~azure.mgmt.msi.v2019_09_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -90,7 +90,7 @@ def get_by_scope( :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SystemAssignedIdentity, or the result of cls(response) - :rtype: ~azure.mgmt.msi.models.SystemAssignedIdentity + :rtype: ~azure.mgmt.msi.v2019_09_01_preview.models.SystemAssignedIdentity :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemAssignedIdentity"] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_user_assigned_identities_operations.py similarity index 97% rename from sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_user_assigned_identities_operations.py rename to sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_user_assigned_identities_operations.py index 97e5afcd63e3..8bce412f6473 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/operations/_user_assigned_identities_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/operations/_user_assigned_identities_operations.py @@ -306,7 +306,7 @@ class UserAssignedIdentitiesOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.models + :type models: ~azure.mgmt.msi.v2019_09_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -331,7 +331,8 @@ def list_by_subscription( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.msi.models.UserAssignedIdentitiesListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2019_09_01_preview.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] @@ -398,7 +399,8 @@ def list_by_resource_group( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.msi.models.UserAssignedIdentitiesListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2019_09_01_preview.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] @@ -488,7 +490,8 @@ def list_associated_resources( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AssociatedResourcesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.msi.models.AssociatedResourcesListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2019_09_01_preview.models.AssociatedResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AssociatedResourcesListResult"] @@ -571,10 +574,10 @@ def create_or_update( :param resource_name: The name of the identity resource. :type resource_name: str :param parameters: Parameters to create or update the identity. - :type parameters: ~azure.mgmt.msi.models.Identity + :type parameters: ~azure.mgmt.msi.v2019_09_01_preview.models.Identity :keyword callable cls: A custom type or function that will be passed the direct response :return: Identity, or the result of cls(response) - :rtype: ~azure.mgmt.msi.models.Identity + :rtype: ~azure.mgmt.msi.v2019_09_01_preview.models.Identity :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] @@ -634,10 +637,10 @@ def update( :param resource_name: The name of the identity resource. :type resource_name: str :param parameters: Parameters to update the identity. - :type parameters: ~azure.mgmt.msi.models.IdentityUpdate + :type parameters: ~azure.mgmt.msi.v2019_09_01_preview.models.IdentityUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: Identity, or the result of cls(response) - :rtype: ~azure.mgmt.msi.models.Identity + :rtype: ~azure.mgmt.msi.v2019_09_01_preview.models.Identity :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] @@ -693,7 +696,7 @@ def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Identity, or the result of cls(response) - :rtype: ~azure.mgmt.msi.models.Identity + :rtype: ~azure.mgmt.msi.v2019_09_01_preview.models.Identity :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Identity"] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/py.typed b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file