diff --git a/sdk/resources/azure-mgmt-msi/CHANGELOG.md b/sdk/resources/azure-mgmt-msi/CHANGELOG.md index 17fde9ca1699..34658a1ff83d 100644 --- a/sdk/resources/azure-mgmt-msi/CHANGELOG.md +++ b/sdk/resources/azure-mgmt-msi/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 6.1.0 (2022-06-29) + +**Features** + + - Added operation group FederatedIdentityCredentialsOperations + ## 6.0.1 (2022-05-05) **Other Changes** diff --git a/sdk/resources/azure-mgmt-msi/MANIFEST.in b/sdk/resources/azure-mgmt-msi/MANIFEST.in index 2c31e8da0cb1..56747e2216c9 100644 --- a/sdk/resources/azure-mgmt-msi/MANIFEST.in +++ b/sdk/resources/azure-mgmt-msi/MANIFEST.in @@ -4,3 +4,4 @@ include *.md include azure/__init__.py include azure/mgmt/__init__.py include LICENSE +include azure/mgmt/msi/py.typed diff --git a/sdk/resources/azure-mgmt-msi/_meta.json b/sdk/resources/azure-mgmt-msi/_meta.json index e847f784bdac..292b701bcaab 100644 --- a/sdk/resources/azure-mgmt-msi/_meta.json +++ b/sdk/resources/azure-mgmt-msi/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.13.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "9722d269ce8ad6bf8de7e8083f0409e8bcb0569f", + "commit": "fda2db441da3f1fab31bb235e97da3e33c8e3903", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/msi/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/msi/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.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/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_managed_service_identity_client.py index 5d55bfc2766d..63e24a871975 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 @@ -90,6 +90,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2018-11-30: :mod:`v2018_11_30.models` * 2021-09-30-preview: :mod:`v2021_09_30_preview.models` + * 2022-01-31-preview: :mod:`v2022_01_31_preview.models` """ if api_version == '2018-11-30': from .v2018_11_30 import models @@ -97,20 +98,39 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-09-30-preview': from .v2021_09_30_preview import models return models + elif api_version == '2022-01-31-preview': + from .v2022_01_31_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) + @property + def federated_identity_credentials(self): + """Instance depends on the API version: + + * 2022-01-31-preview: :class:`FederatedIdentityCredentialsOperations` + """ + api_version = self._get_api_version('federated_identity_credentials') + if api_version == '2022-01-31-preview': + from .v2022_01_31_preview.operations import FederatedIdentityCredentialsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'federated_identity_credentials'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def operations(self): """Instance depends on the API version: * 2018-11-30: :class:`Operations` * 2021-09-30-preview: :class:`Operations` + * 2022-01-31-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 .v2021_09_30_preview.operations import Operations as OperationClass + elif api_version == '2022-01-31-preview': + from .v2022_01_31_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))) @@ -121,12 +141,15 @@ def system_assigned_identities(self): * 2018-11-30: :class:`SystemAssignedIdentitiesOperations` * 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations` + * 2022-01-31-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 .v2021_09_30_preview.operations import SystemAssignedIdentitiesOperations as OperationClass + elif api_version == '2022-01-31-preview': + from .v2022_01_31_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))) @@ -137,12 +160,15 @@ def user_assigned_identities(self): * 2018-11-30: :class:`UserAssignedIdentitiesOperations` * 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations` + * 2022-01-31-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 .v2021_09_30_preview.operations import UserAssignedIdentitiesOperations as OperationClass + elif api_version == '2022-01-31-preview': + from .v2022_01_31_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))) diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_version.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_version.py index 08b59bc06f08..92453d8691d9 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_version.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "6.0.1" +VERSION = "6.1.0" 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 cc2878bc436b..bc8f4a69c466 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 @@ -89,6 +89,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2018-11-30: :mod:`v2018_11_30.models` * 2021-09-30-preview: :mod:`v2021_09_30_preview.models` + * 2022-01-31-preview: :mod:`v2022_01_31_preview.models` """ if api_version == '2018-11-30': from ..v2018_11_30 import models @@ -96,20 +97,39 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-09-30-preview': from ..v2021_09_30_preview import models return models + elif api_version == '2022-01-31-preview': + from ..v2022_01_31_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) + @property + def federated_identity_credentials(self): + """Instance depends on the API version: + + * 2022-01-31-preview: :class:`FederatedIdentityCredentialsOperations` + """ + api_version = self._get_api_version('federated_identity_credentials') + if api_version == '2022-01-31-preview': + from ..v2022_01_31_preview.aio.operations import FederatedIdentityCredentialsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'federated_identity_credentials'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def operations(self): """Instance depends on the API version: * 2018-11-30: :class:`Operations` * 2021-09-30-preview: :class:`Operations` + * 2022-01-31-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 ..v2021_09_30_preview.aio.operations import Operations as OperationClass + elif api_version == '2022-01-31-preview': + from ..v2022_01_31_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))) @@ -120,12 +140,15 @@ def system_assigned_identities(self): * 2018-11-30: :class:`SystemAssignedIdentitiesOperations` * 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations` + * 2022-01-31-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 ..v2021_09_30_preview.aio.operations import SystemAssignedIdentitiesOperations as OperationClass + elif api_version == '2022-01-31-preview': + from ..v2022_01_31_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))) @@ -136,12 +159,15 @@ def user_assigned_identities(self): * 2018-11-30: :class:`UserAssignedIdentitiesOperations` * 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations` + * 2022-01-31-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 ..v2021_09_30_preview.aio.operations import UserAssignedIdentitiesOperations as OperationClass + elif api_version == '2022-01-31-preview': + from ..v2022_01_31_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))) 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 index 2768cf132e10..e2441ca68f4c 100644 --- 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ManagedServiceIdentityClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._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() +_patch_sdk() 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 index 8f2a0ab66064..bacbf1bf0428 100644 --- 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 @@ -58,9 +58,15 @@ def __init__( 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) + 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( 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 index 08b59bc06f08..92453d8691d9 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "6.0.1" +VERSION = "6.1.0" 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 index 7bda71f08efd..8fb6951d1b6d 100644 --- 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._managed_service_identity_client import ManagedServiceIdentityClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ManagedServiceIdentityClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._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() +_patch_sdk() 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 index 67b8a0e5b7e6..6d2a7b358751 100644 --- 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 @@ -58,9 +58,15 @@ def __init__( 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) + 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( diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/__init__.py index 3b14b3b27ba4..1bde43e43173 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/__init__.py @@ -10,8 +10,13 @@ from ._operations import Operations from ._user_assigned_identities_operations import UserAssignedIdentitiesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'SystemAssignedIdentitiesOperations', 'Operations', 'UserAssignedIdentitiesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_operations.py index bbb04fe2f9d1..b80d6789e108 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_operations.py @@ -14,6 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,32 +24,30 @@ 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2018_11_30.aio.ManagedServiceIdentityClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> 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 @@ -57,31 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2018_11_30.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/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 index e6c96f4c5152..b52e02d6df11 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/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 @@ -13,6 +13,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -22,33 +23,31 @@ 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2018_11_30.aio.ManagedServiceIdentityClient`'s + :attr:`system_assigned_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_by_scope( self, scope: str, **kwargs: Any - ) -> "_models.SystemAssignedIdentity": + ) -> _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 @@ -59,24 +58,29 @@ async def get_by_scope( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SystemAssignedIdentity] request = build_get_by_scope_request( scope=scope, api_version=api_version, template_url=self.get_by_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs 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 index 57a8165916cc..7d4e40a609fe 100644 --- 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 @@ -15,6 +15,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -24,32 +25,30 @@ 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2018_11_30.aio.ManagedServiceIdentityClient`'s + :attr:`user_assigned_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.UserAssignedIdentitiesListResult"]: + ) -> 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 @@ -59,13 +58,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2018_11_30.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -73,9 +75,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -83,9 +87,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -123,7 +129,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.UserAssignedIdentitiesListResult"]: + ) -> 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. @@ -135,13 +141,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2018_11_30.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -150,9 +159,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -161,9 +172,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,9 +214,9 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.Identity", + parameters: _models.Identity, **kwargs: Any - ) -> "_models.Identity": + ) -> _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. @@ -217,14 +230,17 @@ async def create_or_update( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] _json = self._serialize.body(parameters, 'Identity') @@ -236,11 +252,13 @@ async def create_or_update( content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -270,9 +288,9 @@ async def update( self, resource_group_name: str, resource_name: str, - parameters: "_models.IdentityUpdate", + parameters: _models.IdentityUpdate, **kwargs: Any - ) -> "_models.Identity": + ) -> _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. @@ -286,14 +304,17 @@ async def update( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] _json = self._serialize.body(parameters, 'IdentityUpdate') @@ -305,11 +326,13 @@ async def update( content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -336,7 +359,7 @@ async def get( resource_group_name: str, resource_name: str, **kwargs: Any - ) -> "_models.Identity": + ) -> _models.Identity: """Gets the identity. :param resource_group_name: The name of the Resource Group to which the identity belongs. @@ -348,13 +371,16 @@ async def get( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] request = build_get_request( @@ -363,11 +389,13 @@ async def get( resource_name=resource_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -406,13 +434,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -421,11 +452,13 @@ async def delete( # pylint: disable=inconsistent-return-statements resource_name=resource_name, api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs 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 index 37575c0dfb74..86b200aef9e4 100644 --- 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 @@ -18,7 +18,9 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserAssignedIdentitiesListResult - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'CloudErrorBody', 'Identity', @@ -32,3 +34,5 @@ 'TrackedResource', 'UserAssignedIdentitiesListResult', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 0c07408ffaa4..3b1f760c45c5 100644 --- 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 @@ -6,10 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class CloudErrorBody(msrest.serialization.Model): """An error response from the ManagedServiceIdentity service. @@ -39,7 +43,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -310,7 +314,7 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): """ @@ -388,7 +392,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -533,7 +537,7 @@ class UserAssignedIdentitiesListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Identity"]] = None, + value: Optional[List["_models.Identity"]] = None, next_link: Optional[str] = None, **kwargs ): diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/__init__.py index 3b14b3b27ba4..1bde43e43173 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/__init__.py @@ -10,8 +10,13 @@ from ._operations import Operations from ._user_assigned_identities_operations import UserAssignedIdentitiesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'SystemAssignedIdentitiesOperations', 'Operations', 'UserAssignedIdentitiesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 67c069c18eb1..90f8da944db9 100644 --- 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 @@ -16,6 +16,7 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + accept = _headers.pop('Accept', "application/json") - 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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **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. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2018_11_30.ManagedServiceIdentityClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> 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 @@ -85,31 +85,38 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2018_11_30.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 index 186382755859..cace7d0c7f03 100644 --- 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 @@ -15,6 +15,7 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models @@ -29,9 +30,12 @@ def build_get_by_scope_request( scope: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.ManagedIdentity/identities/default") path_format_arguments = { @@ -41,49 +45,45 @@ def build_get_by_scope_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **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. +class SystemAssignedIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2018_11_30.ManagedServiceIdentityClient`'s + :attr:`system_assigned_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get_by_scope( self, scope: str, **kwargs: Any - ) -> "_models.SystemAssignedIdentity": + ) -> _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 @@ -94,24 +94,29 @@ def get_by_scope( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SystemAssignedIdentity] request = build_get_by_scope_request( scope=scope, api_version=api_version, template_url=self.get_by_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs 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 index 353e9b95318d..caed272ef090 100644 --- 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 @@ -16,12 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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() @@ -31,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities") # pylint: disable=line-too-long path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_or_update_request( resource_group_name: str, resource_name: str, *, - json: JSONType = None, + json: Optional[_models.Identity] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-11-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_or_update_request( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( resource_group_name: str, resource_name: str, *, - json: JSONType = None, + json: Optional[_models.IdentityUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-11-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,9 +191,12 @@ def build_get_request( resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +208,16 @@ def build_get_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -223,9 +228,12 @@ def build_delete_request( resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -237,48 +245,44 @@ def build_delete_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **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. +class UserAssignedIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2018_11_30.ManagedServiceIdentityClient`'s + :attr:`user_assigned_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.UserAssignedIdentitiesListResult"]: + ) -> 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 @@ -288,13 +292,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2018_11_30.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -302,9 +309,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -312,9 +321,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -352,7 +363,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.UserAssignedIdentitiesListResult"]: + ) -> 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. @@ -364,13 +375,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2018_11_30.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -379,9 +393,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -390,9 +406,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -430,9 +448,9 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.Identity", + parameters: _models.Identity, **kwargs: Any - ) -> "_models.Identity": + ) -> _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. @@ -446,14 +464,17 @@ def create_or_update( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] _json = self._serialize.body(parameters, 'Identity') @@ -465,11 +486,13 @@ def create_or_update( content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -499,9 +522,9 @@ def update( self, resource_group_name: str, resource_name: str, - parameters: "_models.IdentityUpdate", + parameters: _models.IdentityUpdate, **kwargs: Any - ) -> "_models.Identity": + ) -> _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. @@ -515,14 +538,17 @@ def update( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] _json = self._serialize.body(parameters, 'IdentityUpdate') @@ -534,11 +560,13 @@ def update( content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -565,7 +593,7 @@ def get( resource_group_name: str, resource_name: str, **kwargs: Any - ) -> "_models.Identity": + ) -> _models.Identity: """Gets the identity. :param resource_group_name: The name of the Resource Group to which the identity belongs. @@ -577,13 +605,16 @@ def get( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] request = build_get_request( @@ -592,11 +623,13 @@ def get( resource_name=resource_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,13 +668,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-11-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -650,11 +686,13 @@ def delete( # pylint: disable=inconsistent-return-statements resource_name=resource_name, api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/__init__.py index 2768cf132e10..e2441ca68f4c 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ManagedServiceIdentityClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._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() +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_managed_service_identity_client.py index edebb1664404..aaa11ff77224 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_managed_service_identity_client.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_managed_service_identity_client.py @@ -58,9 +58,15 @@ def __init__( 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) + 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( diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_version.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_version.py index 08b59bc06f08..92453d8691d9 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_version.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "6.0.1" +VERSION = "6.1.0" diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/__init__.py index 7bda71f08efd..8fb6951d1b6d 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._managed_service_identity_client import ManagedServiceIdentityClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ManagedServiceIdentityClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._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() +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_managed_service_identity_client.py index bccf505b49cd..7f1ccf80f919 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_managed_service_identity_client.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_managed_service_identity_client.py @@ -58,9 +58,15 @@ def __init__( 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) + 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( diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/__init__.py index 3b14b3b27ba4..1bde43e43173 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/__init__.py @@ -10,8 +10,13 @@ from ._operations import Operations from ._user_assigned_identities_operations import UserAssignedIdentitiesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'SystemAssignedIdentitiesOperations', 'Operations', 'UserAssignedIdentitiesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_operations.py index e339d5dd24b0..1d099e5fd972 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_operations.py @@ -14,6 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,32 +24,30 @@ 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.v2021_09_30_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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2021_09_30_preview.aio.ManagedServiceIdentityClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> 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 @@ -57,31 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_system_assigned_identities_operations.py index 8569eff87efe..2d3a609bbf5a 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_system_assigned_identities_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_system_assigned_identities_operations.py @@ -13,6 +13,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -22,33 +23,31 @@ 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.v2021_09_30_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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2021_09_30_preview.aio.ManagedServiceIdentityClient`'s + :attr:`system_assigned_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_by_scope( self, scope: str, **kwargs: Any - ) -> "_models.SystemAssignedIdentity": + ) -> _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 @@ -59,24 +58,29 @@ async def get_by_scope( :rtype: ~azure.mgmt.msi.v2021_09_30_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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SystemAssignedIdentity] request = build_get_by_scope_request( scope=scope, api_version=api_version, template_url=self.get_by_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_user_assigned_identities_operations.py index 69ee65e775ce..07c2e5554a39 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_user_assigned_identities_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_user_assigned_identities_operations.py @@ -15,6 +15,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -24,32 +25,30 @@ 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.v2021_09_30_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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2021_09_30_preview.aio.ManagedServiceIdentityClient`'s + :attr:`user_assigned_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.UserAssignedIdentitiesListResult"]: + ) -> 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 @@ -59,13 +58,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -73,9 +75,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -83,9 +87,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -123,7 +129,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.UserAssignedIdentitiesListResult"]: + ) -> 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. @@ -135,13 +141,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -150,9 +159,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -161,9 +172,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -207,7 +220,7 @@ def list_associated_resources( skip: Optional[int] = None, skiptoken: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AssociatedResourcesListResult"]: + ) -> AsyncIterable[_models.AssociatedResourcesListResult]: """Lists the associated resources for this identity. :param resource_group_name: The name of the Resource Group to which the identity belongs. @@ -234,13 +247,16 @@ def list_associated_resources( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.AssociatedResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AssociatedResourcesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AssociatedResourcesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -255,9 +271,11 @@ def prepare_request(next_link=None): skip=skip, skiptoken=skiptoken, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -272,9 +290,11 @@ def prepare_request(next_link=None): skip=skip, skiptoken=skiptoken, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -312,9 +332,9 @@ async def create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.Identity", + parameters: _models.Identity, **kwargs: Any - ) -> "_models.Identity": + ) -> _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. @@ -328,14 +348,17 @@ async def create_or_update( :rtype: ~azure.mgmt.msi.v2021_09_30_preview.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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] _json = self._serialize.body(parameters, 'Identity') @@ -347,11 +370,13 @@ async def create_or_update( content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -381,9 +406,9 @@ async def update( self, resource_group_name: str, resource_name: str, - parameters: "_models.IdentityUpdate", + parameters: _models.IdentityUpdate, **kwargs: Any - ) -> "_models.Identity": + ) -> _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. @@ -397,14 +422,17 @@ async def update( :rtype: ~azure.mgmt.msi.v2021_09_30_preview.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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] _json = self._serialize.body(parameters, 'IdentityUpdate') @@ -416,11 +444,13 @@ async def update( content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -447,7 +477,7 @@ async def get( resource_group_name: str, resource_name: str, **kwargs: Any - ) -> "_models.Identity": + ) -> _models.Identity: """Gets the identity. :param resource_group_name: The name of the Resource Group to which the identity belongs. @@ -459,13 +489,16 @@ async def get( :rtype: ~azure.mgmt.msi.v2021_09_30_preview.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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] request = build_get_request( @@ -474,11 +507,13 @@ async def get( resource_name=resource_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -517,13 +552,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -532,11 +570,13 @@ async def delete( # pylint: disable=inconsistent-return-statements resource_name=resource_name, api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/__init__.py index ec960142ee6b..d9a74d051d84 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/__init__.py @@ -20,7 +20,9 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserAssignedIdentitiesListResult - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AssociatedResourcesListResult', 'AzureResource', @@ -36,3 +38,5 @@ 'TrackedResource', 'UserAssignedIdentitiesListResult', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/_models_py3.py index 6dd1ec75d461..2958ff552aec 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/_models_py3.py @@ -6,10 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class AssociatedResourcesListResult(msrest.serialization.Model): """Azure resources returned by the resource action to get a list of assigned resources. @@ -129,7 +133,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -400,7 +404,7 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): """ @@ -478,7 +482,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -623,7 +627,7 @@ class UserAssignedIdentitiesListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Identity"]] = None, + value: Optional[List["_models.Identity"]] = None, next_link: Optional[str] = None, **kwargs ): diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/__init__.py index 3b14b3b27ba4..1bde43e43173 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/__init__.py @@ -10,8 +10,13 @@ from ._operations import Operations from ._user_assigned_identities_operations import UserAssignedIdentitiesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'SystemAssignedIdentitiesOperations', 'Operations', 'UserAssignedIdentitiesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_operations.py index 1967cada808b..eace93b8f46e 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_operations.py @@ -16,6 +16,7 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - 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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **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. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.v2021_09_30_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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2021_09_30_preview.ManagedServiceIdentityClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> 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 @@ -86,31 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_system_assigned_identities_operations.py index 1617181030fc..8cd2a26c11c6 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_system_assigned_identities_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_system_assigned_identities_operations.py @@ -15,6 +15,7 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models @@ -29,9 +30,12 @@ def build_get_by_scope_request( scope: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.ManagedIdentity/identities/default") path_format_arguments = { @@ -41,49 +45,45 @@ def build_get_by_scope_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **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. +class SystemAssignedIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.v2021_09_30_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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2021_09_30_preview.ManagedServiceIdentityClient`'s + :attr:`system_assigned_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get_by_scope( self, scope: str, **kwargs: Any - ) -> "_models.SystemAssignedIdentity": + ) -> _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 @@ -94,24 +94,29 @@ def get_by_scope( :rtype: ~azure.mgmt.msi.v2021_09_30_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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SystemAssignedIdentity] request = build_get_by_scope_request( scope=scope, api_version=api_version, template_url=self.get_by_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_user_assigned_identities_operations.py index e5cdfaa83322..fb9d4ca003e2 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_user_assigned_identities_operations.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_user_assigned_identities_operations.py @@ -16,12 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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() @@ -31,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities") # pylint: disable=line-too-long path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -105,9 +107,12 @@ def build_list_associated_resources_request( skiptoken: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/listAssociatedResources") # pylint: disable=line-too-long path_format_arguments = { @@ -119,28 +124,26 @@ def build_list_associated_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=1) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=1) if skiptoken is not None: - _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -150,14 +153,17 @@ def build_create_or_update_request( resource_group_name: str, resource_name: str, *, - json: JSONType = None, + json: Optional[_models.Identity] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +175,18 @@ def build_create_or_update_request( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -194,14 +198,17 @@ def build_update_request( resource_group_name: str, resource_name: str, *, - json: JSONType = None, + json: Optional[_models.IdentityUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,20 +220,18 @@ def build_update_request( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -239,9 +244,12 @@ def build_get_request( resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -253,18 +261,16 @@ def build_get_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -275,9 +281,12 @@ def build_delete_request( resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -289,48 +298,44 @@ def build_delete_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **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. +class UserAssignedIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.msi.v2021_09_30_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. + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2021_09_30_preview.ManagedServiceIdentityClient`'s + :attr:`user_assigned_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.UserAssignedIdentitiesListResult"]: + ) -> 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 @@ -340,13 +345,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -354,9 +362,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -364,9 +374,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -404,7 +416,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.UserAssignedIdentitiesListResult"]: + ) -> 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. @@ -416,13 +428,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.UserAssignedIdentitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -431,9 +446,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -442,9 +459,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -488,7 +507,7 @@ def list_associated_resources( skip: Optional[int] = None, skiptoken: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AssociatedResourcesListResult"]: + ) -> Iterable[_models.AssociatedResourcesListResult]: """Lists the associated resources for this identity. :param resource_group_name: The name of the Resource Group to which the identity belongs. @@ -515,13 +534,16 @@ def list_associated_resources( ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.AssociatedResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AssociatedResourcesListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AssociatedResourcesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -536,9 +558,11 @@ def prepare_request(next_link=None): skip=skip, skiptoken=skiptoken, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -553,9 +577,11 @@ def prepare_request(next_link=None): skip=skip, skiptoken=skiptoken, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -593,9 +619,9 @@ def create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.Identity", + parameters: _models.Identity, **kwargs: Any - ) -> "_models.Identity": + ) -> _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. @@ -609,14 +635,17 @@ def create_or_update( :rtype: ~azure.mgmt.msi.v2021_09_30_preview.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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] _json = self._serialize.body(parameters, 'Identity') @@ -628,11 +657,13 @@ def create_or_update( content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -662,9 +693,9 @@ def update( self, resource_group_name: str, resource_name: str, - parameters: "_models.IdentityUpdate", + parameters: _models.IdentityUpdate, **kwargs: Any - ) -> "_models.Identity": + ) -> _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. @@ -678,14 +709,17 @@ def update( :rtype: ~azure.mgmt.msi.v2021_09_30_preview.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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] _json = self._serialize.body(parameters, 'IdentityUpdate') @@ -697,11 +731,13 @@ def update( content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -728,7 +764,7 @@ def get( resource_group_name: str, resource_name: str, **kwargs: Any - ) -> "_models.Identity": + ) -> _models.Identity: """Gets the identity. :param resource_group_name: The name of the Resource Group to which the identity belongs. @@ -740,13 +776,16 @@ def get( :rtype: ~azure.mgmt.msi.v2021_09_30_preview.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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] request = build_get_request( @@ -755,11 +794,13 @@ def get( resource_name=resource_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -798,13 +839,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -813,11 +857,13 @@ def delete( # pylint: disable=inconsistent-return-statements resource_name=resource_name, api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/__init__.py new file mode 100644 index 000000000000..e2441ca68f4c --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/__init__.py @@ -0,0 +1,23 @@ +# 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 + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ManagedServiceIdentityClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_configuration.py new file mode 100644 index 000000000000..f81d4971e1e8 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_configuration.py @@ -0,0 +1,73 @@ +# 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): # pylint: disable=too-many-instance-attributes + """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 + :keyword api_version: Api Version. Default value is "2022-01-31-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-31-preview") # type: str + + 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 = api_version + 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/v2022_01_31_preview/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_managed_service_identity_client.py new file mode 100644 index 000000000000..1c8836dbaedb --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_managed_service_identity_client.py @@ -0,0 +1,115 @@ +# 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, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import ManagedServiceIdentityClientConfiguration +from .operations import FederatedIdentityCredentialsOperations, 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.v2022_01_31_preview.operations.SystemAssignedIdentitiesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.msi.v2022_01_31_preview.operations.Operations + :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations + :vartype user_assigned_identities: + azure.mgmt.msi.v2022_01_31_preview.operations.UserAssignedIdentitiesOperations + :ivar federated_identity_credentials: FederatedIdentityCredentialsOperations operations + :vartype federated_identity_credentials: + azure.mgmt.msi.v2022_01_31_preview.operations.FederatedIdentityCredentialsOperations + :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 + :keyword api_version: Api Version. Default value is "2022-01-31-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 + ) + self.federated_identity_credentials = FederatedIdentityCredentialsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: 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/v2022_01_31_preview/_metadata.json b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_metadata.json new file mode 100644 index 000000000000..4a7dbadb90a3 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_metadata.json @@ -0,0 +1,105 @@ +{ + "chosen_version": "2022-01-31-preview", + "total_api_version_list": ["2022-01-31-preview"], + "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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagedServiceIdentityClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagedServiceIdentityClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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", + "federated_identity_credentials": "FederatedIdentityCredentialsOperations" + } +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_vendor.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_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/v2022_01_31_preview/_version.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/_version.py new file mode 100644 index 000000000000..92453d8691d9 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_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 = "6.1.0" diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/__init__.py new file mode 100644 index 000000000000..8fb6951d1b6d --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# 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 + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ManagedServiceIdentityClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/_configuration.py new file mode 100644 index 000000000000..930b49eaec6a --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/_configuration.py @@ -0,0 +1,72 @@ +# 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): # pylint: disable=too-many-instance-attributes + """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 + :keyword api_version: Api Version. Default value is "2022-01-31-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-31-preview") # type: str + + 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 = api_version + 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/v2022_01_31_preview/aio/_managed_service_identity_client.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/_managed_service_identity_client.py new file mode 100644 index 000000000000..54338bd3a566 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/_managed_service_identity_client.py @@ -0,0 +1,112 @@ +# 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, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import ManagedServiceIdentityClientConfiguration +from .operations import FederatedIdentityCredentialsOperations, 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.v2022_01_31_preview.aio.operations.SystemAssignedIdentitiesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.msi.v2022_01_31_preview.aio.operations.Operations + :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations + :vartype user_assigned_identities: + azure.mgmt.msi.v2022_01_31_preview.aio.operations.UserAssignedIdentitiesOperations + :ivar federated_identity_credentials: FederatedIdentityCredentialsOperations operations + :vartype federated_identity_credentials: + azure.mgmt.msi.v2022_01_31_preview.aio.operations.FederatedIdentityCredentialsOperations + :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 + :keyword api_version: Api Version. Default value is "2022-01-31-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 + ) + self.federated_identity_credentials = FederatedIdentityCredentialsOperations( + 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/v2022_01_31_preview/aio/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..fc327c68f423 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# 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 +from ._federated_identity_credentials_operations import FederatedIdentityCredentialsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'SystemAssignedIdentitiesOperations', + 'Operations', + 'UserAssignedIdentitiesOperations', + 'FederatedIdentityCredentialsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_federated_identity_credentials_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_federated_identity_credentials_operations.py new file mode 100644 index 000000000000..ebe685993f3d --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_federated_identity_credentials_operations.py @@ -0,0 +1,359 @@ +# pylint: disable=too-many-lines +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._federated_identity_credentials_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FederatedIdentityCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2022_01_31_preview.aio.ManagedServiceIdentityClient`'s + :attr:`federated_identity_credentials` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.FederatedIdentityCredentialsListResult]: + """Lists all the federated identity credentials under the specified user assigned 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 + :param top: Number of records to return. Default value is None. + :type top: int + :param skiptoken: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FederatedIdentityCredentialsListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredentialsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FederatedIdentityCredentialsListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FederatedIdentityCredentialsListResult", 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( # pylint: disable=protected-access + 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials"} # type: ignore + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + parameters: _models.FederatedIdentityCredential, + **kwargs: Any + ) -> _models.FederatedIdentityCredential: + """Create or update a federated identity credential under the specified user assigned 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 + :param federated_identity_credential_resource_name: The name of the federated identity + credential resource. + :type federated_identity_credential_resource_name: str + :param parameters: Parameters to create or update the federated identity credential. + :type parameters: ~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredential + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FederatedIdentityCredential, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredential + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.FederatedIdentityCredential] + + _json = self._serialize.body(parameters, 'FederatedIdentityCredential') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + federated_identity_credential_resource_name=federated_identity_credential_resource_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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('FederatedIdentityCredential', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FederatedIdentityCredential', 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}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + **kwargs: Any + ) -> _models.FederatedIdentityCredential: + """Gets the federated identity credential. + + :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 federated_identity_credential_resource_name: The name of the federated identity + credential resource. + :type federated_identity_credential_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FederatedIdentityCredential, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredential + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FederatedIdentityCredential] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + federated_identity_credential_resource_name=federated_identity_credential_resource_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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('FederatedIdentityCredential', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + **kwargs: Any + ) -> None: + """Deletes the federated identity credential. + + :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 federated_identity_credential_resource_name: The name of the federated identity + credential resource. + :type federated_identity_credential_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + federated_identity_credential_resource_name=federated_identity_credential_resource_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}"} # type: ignore + diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..9e4213efe30b --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_operations.py @@ -0,0 +1,121 @@ +# pylint: disable=too-many-lines +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar + +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.utils import case_insensitive_dict +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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2022_01_31_preview.aio.ManagedServiceIdentityClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @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.v2022_01_31_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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( # pylint: disable=protected-access + 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/v2022_01_31_preview/aio/operations/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_system_assigned_identities_operations.py new file mode 100644 index 000000000000..d904d641bbf6 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_system_assigned_identities_operations.py @@ -0,0 +1,102 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar + +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.core.utils import case_insensitive_dict +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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2022_01_31_preview.aio.ManagedServiceIdentityClient`'s + :attr:`system_assigned_identities` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @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.v2022_01_31_preview.models.SystemAssignedIdentity + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SystemAssignedIdentity] + + + request = build_get_by_scope_request( + scope=scope, + api_version=api_version, + template_url=self.get_by_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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/v2022_01_31_preview/aio/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_user_assigned_identities_operations.py new file mode 100644 index 000000000000..8ad154d392bd --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/aio/operations/_user_assigned_identities_operations.py @@ -0,0 +1,594 @@ +# pylint: disable=too-many-lines +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar + +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.core.utils import case_insensitive_dict +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_associated_resources_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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2022_01_31_preview.aio.ManagedServiceIdentityClient`'s + :attr:`user_assigned_identities` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @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.v2022_01_31_preview.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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( # pylint: disable=protected-access + 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.v2022_01_31_preview.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + 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, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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( # pylint: disable=protected-access + 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 + def list_associated_resources( + self, + resource_group_name: str, + resource_name: str, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AssociatedResourcesListResult]: + """Lists the associated resources for this 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 + :param filter: OData filter expression to apply to the query. Default value is None. + :type filter: str + :param orderby: OData orderBy expression to apply to the query. Default value is None. + :type orderby: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param skiptoken: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skiptoken: str + :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.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2022_01_31_preview.models.AssociatedResourcesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AssociatedResourcesListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_associated_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + skiptoken=skiptoken, + template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_associated_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + skiptoken=skiptoken, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AssociatedResourcesListResult", 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( # pylint: disable=protected-access + 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_associated_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/listAssociatedResources"} # 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.v2022_01_31_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.v2022_01_31_preview.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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.v2022_01_31_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.v2022_01_31_preview.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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.v2022_01_31_preview.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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( # pylint: disable=inconsistent-return-statements + 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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/v2022_01_31_preview/models/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/models/__init__.py new file mode 100644 index 000000000000..d17b504dde45 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/models/__init__.py @@ -0,0 +1,46 @@ +# 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 AssociatedResourcesListResult +from ._models_py3 import AzureResource +from ._models_py3 import CloudErrorBody +from ._models_py3 import FederatedIdentityCredential +from ._models_py3 import FederatedIdentityCredentialsListResult +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 + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'AssociatedResourcesListResult', + 'AzureResource', + 'CloudErrorBody', + 'FederatedIdentityCredential', + 'FederatedIdentityCredentialsListResult', + 'Identity', + 'IdentityUpdate', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'SystemAssignedIdentity', + 'TrackedResource', + 'UserAssignedIdentitiesListResult', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/models/_models_py3.py new file mode 100644 index 000000000000..ad7df46920f1 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/models/_models_py3.py @@ -0,0 +1,734 @@ +# 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, TYPE_CHECKING + +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AssociatedResourcesListResult(msrest.serialization.Model): + """Azure resources returned by the resource action to get a list of assigned resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar total_count: Total number of Azure resources assigned to the identity. + :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.v2022_01_31_preview.models.AzureResource] + :ivar next_link: The url to get the next page of results, if any. + :vartype next_link: str + """ + + _validation = { + 'total_count': {'readonly': True}, + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'total_count': {'key': 'totalCount', 'type': 'float'}, + 'value': {'key': 'value', 'type': '[AzureResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AssociatedResourcesListResult, self).__init__(**kwargs) + self.total_count = None + self.value = None + self.next_link = None + + +class AzureResource(msrest.serialization.Model): + """Describes an Azure resource that is attached to an identity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of this resource. + :vartype id: str + :ivar name: The name of this resource. + :vartype name: str + :ivar type: The type of this resource. + :vartype type: str + :ivar resource_group: The name of the resource group this resource belongs to. + :vartype resource_group: str + :ivar subscription_id: The ID of the subscription this resource belongs to. + :vartype subscription_id: str + :ivar subscription_display_name: The name of the subscription this resource belongs to. + :vartype subscription_display_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'resource_group': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'subscription_display_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'subscription_display_name': {'key': 'subscriptionDisplayName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AzureResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.resource_group = None + self.subscription_id = None + self.subscription_display_name = None + + +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.v2022_01_31_preview.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["_models.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.v2022_01_31_preview.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 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 FederatedIdentityCredential(ProxyResource): + """Describes a federated identity credential. + + 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 issuer: The URL of the issuer to be trusted. + :vartype issuer: str + :ivar subject: The identifier of the external identity. + :vartype subject: str + :ivar audiences: The list of audiences that can appear in the issued token. + :vartype audiences: list[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'}, + 'issuer': {'key': 'properties.issuer', 'type': 'str'}, + 'subject': {'key': 'properties.subject', 'type': 'str'}, + 'audiences': {'key': 'properties.audiences', 'type': '[str]'}, + } + + def __init__( + self, + *, + issuer: Optional[str] = None, + subject: Optional[str] = None, + audiences: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword issuer: The URL of the issuer to be trusted. + :paramtype issuer: str + :keyword subject: The identifier of the external identity. + :paramtype subject: str + :keyword audiences: The list of audiences that can appear in the issued token. + :paramtype audiences: list[str] + """ + super(FederatedIdentityCredential, self).__init__(**kwargs) + self.issuer = issuer + self.subject = subject + self.audiences = audiences + + +class FederatedIdentityCredentialsListResult(msrest.serialization.Model): + """Values returned by the List operation for federated identity credentials. + + :ivar value: The collection of federated identity credentials returned by the listing + operation. + :vartype value: list[~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredential] + :ivar next_link: The url to get the next page of results, if any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FederatedIdentityCredential]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.FederatedIdentityCredential"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The collection of federated identity credentials returned by the listing + operation. + :paramtype value: list[~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredential] + :keyword next_link: The url to get the next page of results, if any. + :paramtype next_link: str + """ + super(FederatedIdentityCredentialsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +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.v2022_01_31_preview.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.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.v2022_01_31_preview.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.v2022_01_31_preview.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["_models.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.v2022_01_31_preview.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 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.v2022_01_31_preview.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["_models.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.v2022_01_31_preview.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/v2022_01_31_preview/models/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/__init__.py new file mode 100644 index 000000000000..fc327c68f423 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/__init__.py @@ -0,0 +1,24 @@ +# 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 +from ._federated_identity_credentials_operations import FederatedIdentityCredentialsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'SystemAssignedIdentitiesOperations', + 'Operations', + 'UserAssignedIdentitiesOperations', + 'FederatedIdentityCredentialsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_federated_identity_credentials_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_federated_identity_credentials_operations.py new file mode 100644 index 000000000000..408a6e77974a --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_federated_identity_credentials_operations.py @@ -0,0 +1,530 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +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_list_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials") # pylint: disable=line-too-long + 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 + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skiptoken is not None: + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + *, + json: Optional[_models.FederatedIdentityCredential] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}") # pylint: disable=line-too-long + 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'), + "federatedIdentityCredentialResourceName": _SERIALIZER.url("federated_identity_credential_resource_name", federated_identity_credential_resource_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}") # pylint: disable=line-too-long + 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'), + "federatedIdentityCredentialResourceName": _SERIALIZER.url("federated_identity_credential_resource_name", federated_identity_credential_resource_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}") # pylint: disable=line-too-long + 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'), + "federatedIdentityCredentialResourceName": _SERIALIZER.url("federated_identity_credential_resource_name", federated_identity_credential_resource_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class FederatedIdentityCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2022_01_31_preview.ManagedServiceIdentityClient`'s + :attr:`federated_identity_credentials` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.FederatedIdentityCredentialsListResult]: + """Lists all the federated identity credentials under the specified user assigned 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 + :param top: Number of records to return. Default value is None. + :type top: int + :param skiptoken: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FederatedIdentityCredentialsListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredentialsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FederatedIdentityCredentialsListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + top=top, + skiptoken=skiptoken, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("FederatedIdentityCredentialsListResult", 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( # pylint: disable=protected-access + 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials"} # type: ignore + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + parameters: _models.FederatedIdentityCredential, + **kwargs: Any + ) -> _models.FederatedIdentityCredential: + """Create or update a federated identity credential under the specified user assigned 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 + :param federated_identity_credential_resource_name: The name of the federated identity + credential resource. + :type federated_identity_credential_resource_name: str + :param parameters: Parameters to create or update the federated identity credential. + :type parameters: ~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredential + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FederatedIdentityCredential, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredential + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.FederatedIdentityCredential] + + _json = self._serialize.body(parameters, 'FederatedIdentityCredential') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + federated_identity_credential_resource_name=federated_identity_credential_resource_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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('FederatedIdentityCredential', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FederatedIdentityCredential', 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}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + **kwargs: Any + ) -> _models.FederatedIdentityCredential: + """Gets the federated identity credential. + + :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 federated_identity_credential_resource_name: The name of the federated identity + credential resource. + :type federated_identity_credential_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FederatedIdentityCredential, or the result of cls(response) + :rtype: ~azure.mgmt.msi.v2022_01_31_preview.models.FederatedIdentityCredential + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FederatedIdentityCredential] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + federated_identity_credential_resource_name=federated_identity_credential_resource_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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('FederatedIdentityCredential', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + resource_name: str, + federated_identity_credential_resource_name: str, + **kwargs: Any + ) -> None: + """Deletes the federated identity credential. + + :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 federated_identity_credential_resource_name: The name of the federated identity + credential resource. + :type federated_identity_credential_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + federated_identity_credential_resource_name=federated_identity_credential_resource_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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}/federatedIdentityCredentials/{federatedIdentityCredentialResourceName}"} # type: ignore + diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_operations.py new file mode 100644 index 000000000000..4d9a368ad27e --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_operations.py @@ -0,0 +1,151 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ManagedIdentity/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2022_01_31_preview.ManagedServiceIdentityClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @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.v2022_01_31_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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( # pylint: disable=protected-access + 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/v2022_01_31_preview/operations/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_system_assigned_identities_operations.py new file mode 100644 index 000000000000..dd15b50587cd --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_system_assigned_identities_operations.py @@ -0,0 +1,138 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class SystemAssignedIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2022_01_31_preview.ManagedServiceIdentityClient`'s + :attr:`system_assigned_identities` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @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.v2022_01_31_preview.models.SystemAssignedIdentity + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SystemAssignedIdentity] + + + request = build_get_by_scope_request( + scope=scope, + api_version=api_version, + template_url=self.get_by_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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/v2022_01_31_preview/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_user_assigned_identities_operations.py new file mode 100644 index 000000000000..a28aba5f9a62 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/operations/_user_assigned_identities_operations.py @@ -0,0 +1,881 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +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_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_associated_resources_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/listAssociatedResources") # pylint: disable=line-too-long + 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 + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if orderby is not None: + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=1) + if skiptoken is not None: + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: Optional[_models.Identity] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: Optional[_models.IdentityUpdate] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class UserAssignedIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.msi.v2022_01_31_preview.ManagedServiceIdentityClient`'s + :attr:`user_assigned_identities` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @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.v2022_01_31_preview.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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( # pylint: disable=protected-access + 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.v2022_01_31_preview.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserAssignedIdentitiesListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + 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, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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( # pylint: disable=protected-access + 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 list_associated_resources( + self, + resource_group_name: str, + resource_name: str, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AssociatedResourcesListResult]: + """Lists the associated resources for this 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 + :param filter: OData filter expression to apply to the query. Default value is None. + :type filter: str + :param orderby: OData orderBy expression to apply to the query. Default value is None. + :type orderby: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param skiptoken: A skip token is used to continue retrieving items after an operation returns + a partial result. If a previous response contains a nextLink element, the value of the nextLink + element will include a skipToken parameter that specifies a starting point to use for + subsequent calls. Default value is None. + :type skiptoken: str + :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.v2022_01_31_preview.models.AssociatedResourcesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AssociatedResourcesListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_associated_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + skiptoken=skiptoken, + template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_associated_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + skiptoken=skiptoken, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AssociatedResourcesListResult", 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( # pylint: disable=protected-access + 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_associated_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}/listAssociatedResources"} # 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.v2022_01_31_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.v2022_01_31_preview.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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.v2022_01_31_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.v2022_01_31_preview.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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.v2022_01_31_preview.models.Identity + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Identity] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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( # pylint: disable=inconsistent-return-statements + 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-31-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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/v2022_01_31_preview/py.typed b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2022_01_31_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/setup.py b/sdk/resources/azure-mgmt-msi/setup.py index dbaabf971834..c84a02fda3ce 100644 --- a/sdk/resources/azure-mgmt-msi/setup.py +++ b/sdk/resources/azure-mgmt-msi/setup.py @@ -65,10 +65,14 @@ 'azure', 'azure.mgmt', ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, install_requires=[ 'msrest>=0.6.21', 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.0,<2.0.0', + 'azure-mgmt-core>=1.3.1,<2.0.0', ], python_requires=">=3.6" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index fca00c56dc2a..0b856b05ba08 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -296,7 +296,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-securityinsight msrest>=0.6.21 #override azure-mgmt-securityinsight azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-msi msrest>=0.6.21 -#override azure-mgmt-msi azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-msi azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-applicationinsights azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-app msrest>=0.6.21 #override azure-mgmt-app azure-mgmt-core>=1.3.0,<2.0.0