diff --git a/sdk/resources/azure-mgmt-msi/CHANGELOG.md b/sdk/resources/azure-mgmt-msi/CHANGELOG.md index cde7324d38b6..17fde9ca1699 100644 --- a/sdk/resources/azure-mgmt-msi/CHANGELOG.md +++ b/sdk/resources/azure-mgmt-msi/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 6.0.1 (2022-05-05) + +**Other Changes** + + - Change the internal folder name from `v2019_09_01_preview` to `v2021_09_30_preview` + + ## 6.0.0 (2022-03-29) **Breaking changes** diff --git a/sdk/resources/azure-mgmt-msi/_meta.json b/sdk/resources/azure-mgmt-msi/_meta.json index a5150a296f92..e847f784bdac 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.12.0", + "@autorest/python@5.13.0", "@autorest/modelerfour@4.19.3" ], - "commit": "3026119ab41bbce77275cfa3a1afbabf43af5aea", + "commit": "9722d269ce8ad6bf8de7e8083f0409e8bcb0569f", "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.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/msi/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.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 381aee6af425..5d55bfc2766d 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 @@ -11,10 +11,11 @@ from typing import TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import ManagedServiceIdentityClientConfiguration @@ -88,13 +89,13 @@ def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2018-11-30: :mod:`v2018_11_30.models` - * 2021-09-30-preview: :mod:`v2019_09_01_preview.models` + * 2021-09-30-preview: :mod:`v2021_09_30_preview.models` """ if api_version == '2018-11-30': from .v2018_11_30 import models return models elif api_version == '2021-09-30-preview': - from .v2019_09_01_preview import models + from .v2021_09_30_preview import models return models raise ValueError("API version {} is not available".format(api_version)) @@ -103,13 +104,13 @@ def operations(self): """Instance depends on the API version: * 2018-11-30: :class:`Operations` - * 2021-09-30-preview: :class:`Operations` + * 2021-09-30-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2018-11-30': from .v2018_11_30.operations import Operations as OperationClass elif api_version == '2021-09-30-preview': - from .v2019_09_01_preview.operations import Operations as OperationClass + from .v2021_09_30_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))) @@ -119,13 +120,13 @@ def system_assigned_identities(self): """Instance depends on the API version: * 2018-11-30: :class:`SystemAssignedIdentitiesOperations` - * 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations` + * 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations` """ api_version = self._get_api_version('system_assigned_identities') if api_version == '2018-11-30': from .v2018_11_30.operations import SystemAssignedIdentitiesOperations as OperationClass elif api_version == '2021-09-30-preview': - from .v2019_09_01_preview.operations import SystemAssignedIdentitiesOperations as OperationClass + from .v2021_09_30_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))) @@ -135,13 +136,13 @@ def user_assigned_identities(self): """Instance depends on the API version: * 2018-11-30: :class:`UserAssignedIdentitiesOperations` - * 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations` + * 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations` """ api_version = self._get_api_version('user_assigned_identities') if api_version == '2018-11-30': from .v2018_11_30.operations import UserAssignedIdentitiesOperations as OperationClass elif api_version == '2021-09-30-preview': - from .v2019_09_01_preview.operations import UserAssignedIdentitiesOperations as OperationClass + from .v2021_09_30_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 caf312bd2d0b..08b59bc06f08 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.0" +VERSION = "6.0.1" 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 ff9f157bbc78..cc2878bc436b 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 @@ -11,10 +11,11 @@ from typing import Any, Optional, TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import ManagedServiceIdentityClientConfiguration @@ -87,13 +88,13 @@ def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2018-11-30: :mod:`v2018_11_30.models` - * 2021-09-30-preview: :mod:`v2019_09_01_preview.models` + * 2021-09-30-preview: :mod:`v2021_09_30_preview.models` """ if api_version == '2018-11-30': from ..v2018_11_30 import models return models elif api_version == '2021-09-30-preview': - from ..v2019_09_01_preview import models + from ..v2021_09_30_preview import models return models raise ValueError("API version {} is not available".format(api_version)) @@ -102,13 +103,13 @@ def operations(self): """Instance depends on the API version: * 2018-11-30: :class:`Operations` - * 2021-09-30-preview: :class:`Operations` + * 2021-09-30-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2018-11-30': from ..v2018_11_30.aio.operations import Operations as OperationClass elif api_version == '2021-09-30-preview': - from ..v2019_09_01_preview.aio.operations import Operations as OperationClass + from ..v2021_09_30_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))) @@ -118,13 +119,13 @@ def system_assigned_identities(self): """Instance depends on the API version: * 2018-11-30: :class:`SystemAssignedIdentitiesOperations` - * 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations` + * 2021-09-30-preview: :class:`SystemAssignedIdentitiesOperations` """ api_version = self._get_api_version('system_assigned_identities') if api_version == '2018-11-30': from ..v2018_11_30.aio.operations import SystemAssignedIdentitiesOperations as OperationClass elif api_version == '2021-09-30-preview': - from ..v2019_09_01_preview.aio.operations import SystemAssignedIdentitiesOperations as OperationClass + from ..v2021_09_30_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))) @@ -134,13 +135,13 @@ def user_assigned_identities(self): """Instance depends on the API version: * 2018-11-30: :class:`UserAssignedIdentitiesOperations` - * 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations` + * 2021-09-30-preview: :class:`UserAssignedIdentitiesOperations` """ api_version = self._get_api_version('user_assigned_identities') if api_version == '2018-11-30': from ..v2018_11_30.aio.operations import UserAssignedIdentitiesOperations as OperationClass elif api_version == '2021-09-30-preview': - from ..v2019_09_01_preview.aio.operations import UserAssignedIdentitiesOperations as OperationClass + from ..v2021_09_30_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/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_configuration.py index d5f791ffbae5..ea2702cf00e9 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_configuration.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class ManagedServiceIdentityClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class ManagedServiceIdentityClientConfiguration(Configuration): :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 "2018-11-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-11-30" + 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) 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 2b8363f8e28d..8f2a0ab66064 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import ManagedServiceIdentityClientConfiguration @@ -36,8 +37,11 @@ class ManagedServiceIdentityClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Id of the Subscription to which the identity belongs. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-11-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -61,7 +65,7 @@ def __init__( def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_metadata.json b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_metadata.json index 2afb48779cf2..4fea955391a8 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_metadata.json +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagedServiceIdentityClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagedServiceIdentityClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "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": { 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 caf312bd2d0b..08b59bc06f08 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.0" +VERSION = "6.0.1" diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_configuration.py index c303ee873d5b..9b0733f847f4 100644 --- a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ManagedServiceIdentityClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class ManagedServiceIdentityClientConfiguration(Configuration): :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 "2018-11-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(ManagedServiceIdentityClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-11-30" + 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) 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 00eb93bc39c9..67b8a0e5b7e6 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import ManagedServiceIdentityClientConfiguration @@ -36,8 +37,11 @@ class ManagedServiceIdentityClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Id of the Subscription to which the identity belongs. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-11-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( 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 df52901f6b37..bbb04fe2f9d1 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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 @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -59,6 +57,8 @@ 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 + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -68,6 +68,7 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], ) request = _convert_request(request) @@ -76,6 +77,7 @@ def prepare_request(next_link=None): else: request = build_list_request( + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -93,7 +95,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -106,4 +112,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ManagedIdentity/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ManagedIdentity/operations"} # type: ignore 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 28eda463f6d1..e6c96f4c5152 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -66,15 +65,22 @@ async def get_by_scope( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + request = build_get_by_scope_request( scope=scope, + api_version=api_version, template_url=self.get_by_scope.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -88,5 +94,5 @@ async def get_by_scope( return deserialized - get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.ManagedIdentity/identities/default'} # type: ignore + get_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.ManagedIdentity/identities/default"} # type: ignore diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/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 150dab25730b..57a8165916cc 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from 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 @@ -60,6 +59,8 @@ 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 + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -70,6 +71,7 @@ def prepare_request(next_link=None): request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription.metadata['url'], ) request = _convert_request(request) @@ -79,6 +81,7 @@ def prepare_request(next_link=None): request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -96,7 +99,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -109,7 +116,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities"} # type: ignore @distributed_trace def list_by_resource_group( @@ -128,6 +135,8 @@ 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 + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -139,6 +148,7 @@ def prepare_request(next_link=None): 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'], ) request = _convert_request(request) @@ -149,6 +159,7 @@ def prepare_request(next_link=None): 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, ) request = _convert_request(request) @@ -166,7 +177,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -179,7 +194,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities"} # type: ignore @distributed_trace_async async def create_or_update( @@ -208,6 +223,7 @@ async def create_or_update( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] _json = self._serialize.body(parameters, 'Identity') @@ -216,6 +232,7 @@ async def create_or_update( 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'], @@ -223,7 +240,11 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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, 201]: @@ -241,7 +262,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}"} # type: ignore @distributed_trace_async @@ -271,6 +292,7 @@ async def update( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] _json = self._serialize.body(parameters, 'IdentityUpdate') @@ -279,6 +301,7 @@ async def update( 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'], @@ -286,7 +309,11 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -300,7 +327,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}"} # type: ignore @distributed_trace_async @@ -327,17 +354,24 @@ async def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + 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'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -351,11 +385,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, resource_name: str, @@ -378,17 +412,24 @@ async def delete( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + 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'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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, 204]: @@ -398,5 +439,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_operations.py index 62c8e77bdfce..67c069c18eb1 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,24 +29,25 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-30" + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.ManagedIdentity/operations') + _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') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -84,6 +85,8 @@ 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 + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -93,6 +96,7 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], ) request = _convert_request(request) @@ -101,6 +105,7 @@ def prepare_request(next_link=None): else: request = build_list_request( + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -118,7 +123,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -131,4 +140,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ManagedIdentity/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ManagedIdentity/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_system_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_system_assigned_identities_operations.py index b3a8f5e4f8b7..186382755859 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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 @@ -15,7 +16,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -29,29 +29,30 @@ def build_get_by_scope_request( scope: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-30" + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedIdentity/identities/default') + _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) + _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') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -99,15 +100,22 @@ def get_by_scope( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + request = build_get_by_scope_request( scope=scope, + api_version=api_version, template_url=self.get_by_scope.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -121,5 +129,5 @@ def get_by_scope( return deserialized - get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.ManagedIdentity/identities/default'} # type: ignore + get_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.ManagedIdentity/identities/default"} # type: ignore diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_user_assigned_identities_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2018_11_30/operations/_user_assigned_identities_operations.py index 853b34e439a0..353e9b95318d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,29 +31,30 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-30" + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities') + _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) + _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') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -63,30 +64,31 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-30" + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities') + _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) + _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') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -100,35 +102,35 @@ def build_create_or_update_request( 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] - api_version = "2018-11-30" accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}') + _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) + _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') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters = 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') + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, json=json, content=content, **kwargs @@ -144,35 +146,35 @@ def build_update_request( 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] - api_version = "2018-11-30" accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}') + _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) + _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') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters = 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') + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, json=json, content=content, **kwargs @@ -185,31 +187,32 @@ def build_get_request( resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-30" + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}') + _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) + _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') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -220,31 +223,32 @@ def build_delete_request( resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-30" + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}') + _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) + _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') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -284,6 +288,8 @@ 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 + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -294,6 +300,7 @@ def prepare_request(next_link=None): request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription.metadata['url'], ) request = _convert_request(request) @@ -303,6 +310,7 @@ def prepare_request(next_link=None): request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -320,7 +328,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -333,7 +345,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ManagedIdentity/userAssignedIdentities"} # type: ignore @distributed_trace def list_by_resource_group( @@ -352,6 +364,8 @@ 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 + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserAssignedIdentitiesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -363,6 +377,7 @@ def prepare_request(next_link=None): 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'], ) request = _convert_request(request) @@ -373,6 +388,7 @@ def prepare_request(next_link=None): 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, ) request = _convert_request(request) @@ -390,7 +406,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -403,7 +423,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities"} # type: ignore @distributed_trace def create_or_update( @@ -432,6 +452,7 @@ def create_or_update( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] _json = self._serialize.body(parameters, 'Identity') @@ -440,6 +461,7 @@ def create_or_update( 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'], @@ -447,7 +469,11 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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, 201]: @@ -465,7 +491,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}"} # type: ignore @distributed_trace @@ -495,6 +521,7 @@ def update( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] _json = self._serialize.body(parameters, 'IdentityUpdate') @@ -503,6 +530,7 @@ def update( 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'], @@ -510,7 +538,11 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -524,7 +556,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}"} # type: ignore @distributed_trace @@ -551,17 +583,24 @@ def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + 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'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -575,11 +614,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, resource_name: str, @@ -602,17 +641,24 @@ def delete( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2018-11-30") # type: str + 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'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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, 204]: @@ -622,5 +668,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}'} # type: ignore + 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/v2021_09_30_preview/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/__init__.py new file mode 100644 index 000000000000..2768cf132e10 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._managed_service_identity_client import ManagedServiceIdentityClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['ManagedServiceIdentityClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_configuration.py new file mode 100644 index 000000000000..64a9db725e08 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_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 "2021-09-30-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', "2021-09-30-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/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 new file mode 100644 index 000000000000..edebb1664404 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_managed_service_identity_client.py @@ -0,0 +1,103 @@ +# 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 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.v2021_09_30_preview.operations.SystemAssignedIdentitiesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.msi.v2021_09_30_preview.operations.Operations + :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations + :vartype user_assigned_identities: + azure.mgmt.msi.v2021_09_30_preview.operations.UserAssignedIdentitiesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Id of the Subscription to which the identity belongs. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-30-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) + + + 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/v2021_09_30_preview/_metadata.json b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_metadata.json new file mode 100644 index 000000000000..d336b7949ec9 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_metadata.json @@ -0,0 +1,104 @@ +{ + "chosen_version": "2021-09-30-preview", + "total_api_version_list": ["2021-09-30-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" + } +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_vendor.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_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/v2021_09_30_preview/_version.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/_version.py new file mode 100644 index 000000000000..08b59bc06f08 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_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.0.1" 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 new file mode 100644 index 000000000000..7bda71f08efd --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._managed_service_identity_client import ManagedServiceIdentityClient +__all__ = ['ManagedServiceIdentityClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_configuration.py new file mode 100644 index 000000000000..a914534d7cee --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_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 "2021-09-30-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', "2021-09-30-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/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 new file mode 100644 index 000000000000..bccf505b49cd --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_managed_service_identity_client.py @@ -0,0 +1,100 @@ +# 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 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.v2021_09_30_preview.aio.operations.SystemAssignedIdentitiesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.msi.v2021_09_30_preview.aio.operations.Operations + :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations + :vartype user_assigned_identities: + azure.mgmt.msi.v2021_09_30_preview.aio.operations.UserAssignedIdentitiesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Id of the Subscription to which the identity belongs. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-30-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) + + + 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/v2021_09_30_preview/aio/_patch.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/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 new file mode 100644 index 000000000000..3b14b3b27ba4 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._system_assigned_identities_operations import SystemAssignedIdentitiesOperations +from ._operations import Operations +from ._user_assigned_identities_operations import UserAssignedIdentitiesOperations + +__all__ = [ + 'SystemAssignedIdentitiesOperations', + 'Operations', + 'UserAssignedIdentitiesOperations', +] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/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 new file mode 100644 index 000000000000..e339d5dd24b0 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_operations.py @@ -0,0 +1,115 @@ +# 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists available operations for the Microsoft.ManagedIdentity provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-09-30-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', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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/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 new file mode 100644 index 000000000000..8569eff87efe --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_system_assigned_identities_operations.py @@ -0,0 +1,98 @@ +# 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._system_assigned_identities_operations import build_get_by_scope_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SystemAssignedIdentitiesOperations: + """SystemAssignedIdentitiesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get_by_scope( + self, + scope: str, + **kwargs: Any + ) -> "_models.SystemAssignedIdentity": + """Gets the systemAssignedIdentity available under the specified RP scope. + + :param scope: The resource provider scope of the resource. Parent resource being extended by + Managed Identities. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SystemAssignedIdentity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.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', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + + request = build_get_by_scope_request( + scope=scope, + api_version=api_version, + template_url=self.get_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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/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 new file mode 100644 index 000000000000..69ee65e775ce --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/aio/operations/_user_assigned_identities_operations.py @@ -0,0 +1,554 @@ +# 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.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: + """UserAssignedIdentitiesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.UserAssignedIdentitiesListResult"]: + """Lists all the userAssignedIdentities available under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-09-30-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', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UserAssignedIdentitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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.v2021_09_30_preview.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-09-30-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', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UserAssignedIdentitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # 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.v2021_09_30_preview.models.AssociatedResourcesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-09-30-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', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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.v2021_09_30_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.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', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Identity') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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.v2021_09_30_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.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', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IdentityUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # 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.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', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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/v2021_09_30_preview/models/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/__init__.py new file mode 100644 index 000000000000..ec960142ee6b --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/__init__.py @@ -0,0 +1,38 @@ +# 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 Identity +from ._models_py3 import IdentityUpdate +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import SystemAssignedIdentity +from ._models_py3 import TrackedResource +from ._models_py3 import UserAssignedIdentitiesListResult + + +__all__ = [ + 'AssociatedResourcesListResult', + 'AzureResource', + 'CloudErrorBody', + 'Identity', + 'IdentityUpdate', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'SystemAssignedIdentity', + 'TrackedResource', + 'UserAssignedIdentitiesListResult', +] 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 new file mode 100644 index 000000000000..6dd1ec75d461 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/models/_models_py3.py @@ -0,0 +1,638 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional + +import msrest.serialization + + +class 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.v2021_09_30_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.v2021_09_30_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["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.v2021_09_30_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 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.v2021_09_30_preview.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + """ + :keyword name: The name of the REST Operation. This is of the format + {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that describes the operation. + :paramtype display: ~azure.mgmt.msi.v2021_09_30_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.v2021_09_30_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["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.v2021_09_30_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 ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class SystemAssignedIdentity(ProxyResource): + """Describes a system assigned identity resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar tenant_id: The id of the tenant which the identity belongs to. + :vartype tenant_id: str + :ivar principal_id: The id of the service principal object associated with the created + identity. + :vartype principal_id: str + :ivar client_id: The id of the app associated with the identity. This is a random generated + UUID by MSI. + :vartype client_id: str + :ivar client_secret_url: The ManagedServiceIdentity DataPlane URL that can be queried to obtain + the identity credentials. + :vartype client_secret_url: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'tenant_id': {'readonly': True}, + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + 'client_secret_url': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'client_id': {'key': 'properties.clientId', 'type': 'str'}, + 'client_secret_url': {'key': 'properties.clientSecretUrl', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(SystemAssignedIdentity, self).__init__(**kwargs) + self.location = location + self.tags = tags + self.tenant_id = None + self.principal_id = None + self.client_id = None + self.client_secret_url = None + + +class UserAssignedIdentitiesListResult(msrest.serialization.Model): + """Values returned by the List operation. + + :ivar value: The collection of userAssignedIdentities returned by the listing operation. + :vartype value: list[~azure.mgmt.msi.v2021_09_30_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["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.v2021_09_30_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/v2021_09_30_preview/operations/__init__.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/__init__.py new file mode 100644 index 000000000000..3b14b3b27ba4 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._system_assigned_identities_operations import SystemAssignedIdentitiesOperations +from ._operations import Operations +from ._user_assigned_identities_operations import UserAssignedIdentitiesOperations + +__all__ = [ + 'SystemAssignedIdentitiesOperations', + 'Operations', + 'UserAssignedIdentitiesOperations', +] diff --git a/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_operations.py b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_operations.py new file mode 100644 index 000000000000..1967cada808b --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_operations.py @@ -0,0 +1,144 @@ +# 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.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: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ManagedIdentity/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """Lists available operations for the Microsoft.ManagedIdentity provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-09-30-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', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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/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 new file mode 100644 index 000000000000..1617181030fc --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_system_assigned_identities_operations.py @@ -0,0 +1,133 @@ +# 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.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: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.ManagedIdentity/identities/default") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class SystemAssignedIdentitiesOperations(object): + """SystemAssignedIdentitiesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get_by_scope( + self, + scope: str, + **kwargs: Any + ) -> "_models.SystemAssignedIdentity": + """Gets the systemAssignedIdentity available under the specified RP scope. + + :param scope: The resource provider scope of the resource. Parent resource being extended by + Managed Identities. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SystemAssignedIdentity, or the result of cls(response) + :rtype: ~azure.mgmt.msi.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', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + + request = build_get_by_scope_request( + scope=scope, + api_version=api_version, + template_url=self.get_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # 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/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 new file mode 100644 index 000000000000..e5cdfaa83322 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/operations/_user_assigned_identities_operations.py @@ -0,0 +1,835 @@ +# 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.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() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + 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 + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + 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 + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_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: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + 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 + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if orderby is not None: + _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + _query_parameters['$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') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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 + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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 + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + 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 + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + 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 + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class UserAssignedIdentitiesOperations(object): + """UserAssignedIdentitiesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.msi.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.UserAssignedIdentitiesListResult"]: + """Lists all the userAssignedIdentities available under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserAssignedIdentitiesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.msi.v2021_09_30_preview.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-09-30-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', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UserAssignedIdentitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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.v2021_09_30_preview.models.UserAssignedIdentitiesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-09-30-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', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UserAssignedIdentitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # 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.v2021_09_30_preview.models.AssociatedResourcesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-09-30-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', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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.v2021_09_30_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.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', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Identity') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # 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.v2021_09_30_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.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', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IdentityUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # 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.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', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-09-30-preview") # type: str + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, 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/v2021_09_30_preview/py.typed b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2021_09_30_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file