diff --git a/sdk/maps/azure-mgmt-maps/_meta.json b/sdk/maps/azure-mgmt-maps/_meta.json index 5abd014b76adb..26a98dd1a0709 100644 --- a/sdk/maps/azure-mgmt-maps/_meta.json +++ b/sdk/maps/azure-mgmt-maps/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.6", - "commit": "5e6a5758c2bd7128984f131be88200cd4d2d1a17", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "e8c6db17dc13a00155936dcaeacf4da0a1fabf77", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/maps/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0", + "autorest_command": "autorest specification/maps/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/maps/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/__init__.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/__init__.py index c07473b586ca2..588fbef3ef891 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/__init__.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AzureMapsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._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/maps/azure-mgmt-maps/azure/mgmt/maps/_azure_maps_management_client.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_azure_maps_management_client.py index a774b587a3b72..bd3dc9c257d53 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_azure_maps_management_client.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_azure_maps_management_client.py @@ -6,26 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import AzureMapsManagementClientConfiguration +from .operations import AccountsOperations, CreatorsOperations, MapsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AzureMapsManagementClientConfiguration -from .operations import AccountsOperations -from .operations import MapsOperations -from .operations import CreatorsOperations -from . import models - -class AzureMapsManagementClient(object): +class AzureMapsManagementClient: """Azure Maps. :ivar accounts: AccountsOperations operations @@ -38,51 +34,54 @@ class AzureMapsManagementClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureMapsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureMapsManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.maps = MapsOperations(self._client, self._config, self._serialize, self._deserialize) + self.creators = CreatorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maps = MapsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.creators = CreatorsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_configuration.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_configuration.py index d5fcc9aba9ec6..d4430f437de50 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_configuration.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,20 +33,19 @@ class AzureMapsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AzureMapsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AzureMapsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-02-01" + self.api_version = "2021-12-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-maps/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +65,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_metadata.json b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_metadata.json index 7666e54fab3e7..076a77aaf90bf 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_metadata.json +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2021-02-01", - "total_api_version_list": ["2021-02-01"], + "chosen_version": "2021-12-01-preview", + "total_api_version_list": ["2021-12-01-preview"], "client": { "name": "AzureMapsManagementClient", "filename": "_azure_maps_management_client", "description": "Azure Maps.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureMapsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureMapsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"AzureMapsManagementClientConfiguration\"]}}, \"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\": [\"AzureMapsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "accounts": "AccountsOperations", diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_patch.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_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/maps/azure-mgmt-maps/azure/mgmt/maps/_vendor.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_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/maps/azure-mgmt-maps/azure/mgmt/maps/_version.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_version.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/__init__.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/__init__.py index 10be33448706e..4f0e4233b18d6 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/__init__.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/__init__.py @@ -8,3 +8,8 @@ from ._azure_maps_management_client import AzureMapsManagementClient __all__ = ['AzureMapsManagementClient'] + +# `._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/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_azure_maps_management_client.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_azure_maps_management_client.py index 61b83bfe182e3..7e72c0b62b0ef 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_azure_maps_management_client.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_azure_maps_management_client.py @@ -6,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import AzureMapsManagementClientConfiguration +from .operations import AccountsOperations, CreatorsOperations, MapsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import AzureMapsManagementClientConfiguration -from .operations import AccountsOperations -from .operations import MapsOperations -from .operations import CreatorsOperations -from .. import models - - -class AzureMapsManagementClient(object): +class AzureMapsManagementClient: """Azure Maps. :ivar accounts: AccountsOperations operations @@ -36,49 +34,54 @@ class AzureMapsManagementClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureMapsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AzureMapsManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.maps = MapsOperations(self._client, self._config, self._serialize, self._deserialize) + self.creators = CreatorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maps = MapsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.creators = CreatorsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_configuration.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_configuration.py index 110554230d496..becbbd70fcbb7 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_configuration.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AzureMapsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AzureMapsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-02-01" + self.api_version = "2021-12-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-maps/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +64,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_patch.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/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/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_accounts_operations.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_accounts_operations.py index 96064db1fe6f7..63494825a3d91 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_accounts_operations.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_accounts_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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._accounts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_keys_request, build_list_sas_request, build_regenerate_keys_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, account_name: str, maps_account: "_models.MapsAccount", - **kwargs + **kwargs: Any ) -> "_models.MapsAccount": """Create or update a Maps Account. A Maps Account holds the keys which allow access to the Maps REST APIs. @@ -67,38 +73,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(maps_account, 'MapsAccount') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(maps_account, 'MapsAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -111,14 +107,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, account_name: str, maps_account_update_parameters: "_models.MapsAccountUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.MapsAccount": """Updates a Maps Account. Only a subset of the parameters may be updated after creation, such as Sku, Tags, Properties. @@ -139,38 +138,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(maps_account_update_parameters, 'MapsAccountUpdateParameters') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(maps_account_update_parameters, 'MapsAccountUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MapsAccount', pipeline_response) @@ -179,13 +168,16 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, account_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete a Maps Account. @@ -203,33 +195,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -237,11 +219,13 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - **kwargs + **kwargs: Any ) -> "_models.MapsAccount": """Get a Maps Account. @@ -259,33 +243,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MapsAccount', pipeline_response) @@ -294,12 +268,15 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.MapsAccounts"]: """Get all Maps Accounts in a Resource Group. @@ -315,35 +292,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MapsAccounts', pipeline_response) + deserialized = self._deserialize("MapsAccounts", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -356,20 +329,22 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.MapsAccounts"]: """Get all Maps Accounts in a Subscription. @@ -383,34 +358,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MapsAccounts', pipeline_response) + deserialized = self._deserialize("MapsAccounts", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -423,22 +393,93 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maps/accounts'} # type: ignore + @distributed_trace_async + async def list_sas( + self, + resource_group_name: str, + account_name: str, + maps_account_sas_parameters: "_models.AccountSasParameters", + **kwargs: Any + ) -> "_models.MapsAccountSasToken": + """Create and list an account shared access signature token. Use this SAS token for authentication + to Azure Maps REST APIs through various Azure Maps SDKs. As prerequisite to create a SAS Token. + + Prerequisites: + + + #. Create or have an existing User Assigned Managed Identity in the same Azure region as the + account. + #. Create or update an Azure Map account with the same Azure region as the User Assigned + Managed Identity is placed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the Maps Account. + :type account_name: str + :param maps_account_sas_parameters: The updated parameters for the Maps Account. + :type maps_account_sas_parameters: ~azure.mgmt.maps.models.AccountSasParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MapsAccountSasToken, or the result of cls(response) + :rtype: ~azure.mgmt.maps.models.MapsAccountSasToken + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MapsAccountSasToken"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(maps_account_sas_parameters, 'AccountSasParameters') + + request = build_list_sas_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self.list_sas.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MapsAccountSasToken', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listSas'} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, - **kwargs + **kwargs: Any ) -> "_models.MapsAccountKeys": """Get the keys to use with the Maps APIs. A key is used to authenticate and authorize access to the Maps REST APIs. Only one key is needed at a time; two are given to provide seamless key @@ -458,33 +499,23 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MapsAccountKeys', pipeline_response) @@ -493,14 +524,17 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listKeys'} # type: ignore + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, account_name: str, key_specification: "_models.MapsKeySpecification", - **kwargs + **kwargs: Any ) -> "_models.MapsAccountKeys": """Regenerate either the primary or secondary key for use with the Maps APIs. The old key will stop working immediately. @@ -521,38 +555,28 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(key_specification, 'MapsKeySpecification') + + request = build_regenerate_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(key_specification, 'MapsKeySpecification') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MapsAccountKeys', pipeline_response) @@ -561,4 +585,6 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized + regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/regenerateKey'} # type: ignore + diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_creators_operations.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_creators_operations.py index d4f43e80131a5..d1f1464700df3 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_creators_operations.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_creators_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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._creators_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_account_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_account( self, resource_group_name: str, account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.CreatorList"]: """Get all Creator instances for an Azure Maps Account. @@ -63,36 +69,33 @@ def list_by_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_by_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CreatorList', pipeline_response) + deserialized = self._deserialize("CreatorList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,24 +108,26 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators'} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, account_name: str, creator_name: str, creator_resource: "_models.Creator", - **kwargs + **kwargs: Any ) -> "_models.Creator": """Create or update a Maps Creator resource. Creator resource will manage Azure resources required to populate a custom set of mapping data. It requires an account to exist before it can be @@ -146,39 +151,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'creatorName': self._serialize.url("creator_name", creator_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(creator_resource, 'Creator') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + creator_name=creator_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(creator_resource, 'Creator') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -191,15 +186,18 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, account_name: str, creator_name: str, creator_update_parameters: "_models.CreatorUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.Creator": """Updates the Maps Creator resource. Only a subset of the parameters may be updated after creation, such as Tags. @@ -222,39 +220,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'creatorName': self._serialize.url("creator_name", creator_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(creator_update_parameters, 'CreatorUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + creator_name=creator_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(creator_update_parameters, 'CreatorUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Creator', pipeline_response) @@ -263,14 +251,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, account_name: str, creator_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete a Maps Creator resource. @@ -290,34 +281,24 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'creatorName': self._serialize.url("creator_name", creator_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + creator_name=creator_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -325,12 +306,14 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, creator_name: str, - **kwargs + **kwargs: Any ) -> "_models.Creator": """Get a Maps Creator resource. @@ -350,34 +333,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'creatorName': self._serialize.url("creator_name", creator_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + creator_name=creator_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Creator', pipeline_response) @@ -386,4 +359,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}'} # type: ignore + diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_maps_operations.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_maps_operations.py index 8800e9dbe9651..499109df12a66 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_maps_operations.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/aio/operations/_maps_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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._maps_operations import build_list_operations_request, build_list_subscription_operations_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,9 +46,10 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_operations( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.MapsOperations"]: """List operations available for the Maps Resource Provider. @@ -57,30 +63,27 @@ def list_operations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_operations.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_operations_request( + template_url=self.list_operations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_operations_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MapsOperations', pipeline_response) + deserialized = self._deserialize("MapsOperations", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,13 +96,78 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_operations.metadata = {'url': '/providers/Microsoft.Maps/operations'} # type: ignore + + @distributed_trace + def list_subscription_operations( + self, + **kwargs: Any + ) -> AsyncIterable["_models.MapsOperations"]: + """List operations available for the Maps Resource Provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MapsOperations or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maps.models.MapsOperations] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MapsOperations"] + 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_subscription_operations_request( + subscription_id=self._config.subscription_id, + template_url=self.list_subscription_operations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_subscription_operations_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MapsOperations", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_subscription_operations.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maps/operations'} # type: ignore diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/__init__.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/__init__.py index 987f1687d7123..a212d1d9de999 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/__init__.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/__init__.py @@ -6,63 +6,52 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Creator - from ._models_py3 import CreatorList - from ._models_py3 import CreatorProperties - from ._models_py3 import CreatorUpdateParameters - from ._models_py3 import Dimension - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import MapsAccount - from ._models_py3 import MapsAccountKeys - from ._models_py3 import MapsAccountProperties - from ._models_py3 import MapsAccountUpdateParameters - from ._models_py3 import MapsAccounts - from ._models_py3 import MapsKeySpecification - from ._models_py3 import MapsOperations - from ._models_py3 import MetricSpecification - from ._models_py3 import OperationDetail - from ._models_py3 import OperationDisplay - from ._models_py3 import Resource - from ._models_py3 import ServiceSpecification - from ._models_py3 import Sku - from ._models_py3 import SystemData - from ._models_py3 import TrackedResource -except (SyntaxError, ImportError): - from ._models import Creator # type: ignore - from ._models import CreatorList # type: ignore - from ._models import CreatorProperties # type: ignore - from ._models import CreatorUpdateParameters # type: ignore - from ._models import Dimension # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import MapsAccount # type: ignore - from ._models import MapsAccountKeys # type: ignore - from ._models import MapsAccountProperties # type: ignore - from ._models import MapsAccountUpdateParameters # type: ignore - from ._models import MapsAccounts # type: ignore - from ._models import MapsKeySpecification # type: ignore - from ._models import MapsOperations # type: ignore - from ._models import MetricSpecification # type: ignore - from ._models import OperationDetail # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import Resource # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Sku # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackedResource # type: ignore +from ._models_py3 import AccountSasParameters +from ._models_py3 import Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties +from ._models_py3 import CorsRule +from ._models_py3 import CorsRules +from ._models_py3 import Creator +from ._models_py3 import CreatorList +from ._models_py3 import CreatorProperties +from ._models_py3 import CreatorUpdateParameters +from ._models_py3 import Dimension +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import LinkedResource +from ._models_py3 import ManagedServiceIdentity +from ._models_py3 import MapsAccount +from ._models_py3 import MapsAccountKeys +from ._models_py3 import MapsAccountProperties +from ._models_py3 import MapsAccountSasToken +from ._models_py3 import MapsAccountUpdateParameters +from ._models_py3 import MapsAccounts +from ._models_py3 import MapsKeySpecification +from ._models_py3 import MapsOperations +from ._models_py3 import MetricSpecification +from ._models_py3 import OperationDetail +from ._models_py3 import OperationDisplay +from ._models_py3 import Resource +from ._models_py3 import ServiceSpecification +from ._models_py3 import Sku +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource + from ._azure_maps_management_client_enums import ( CreatedByType, KeyType, Kind, Name, + ResourceIdentityType, + SigningKey, ) __all__ = [ + 'AccountSasParameters', + 'Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties', + 'CorsRule', + 'CorsRules', 'Creator', 'CreatorList', 'CreatorProperties', @@ -71,9 +60,12 @@ 'ErrorAdditionalInfo', 'ErrorDetail', 'ErrorResponse', + 'LinkedResource', + 'ManagedServiceIdentity', 'MapsAccount', 'MapsAccountKeys', 'MapsAccountProperties', + 'MapsAccountSasToken', 'MapsAccountUpdateParameters', 'MapsAccounts', 'MapsKeySpecification', @@ -90,4 +82,6 @@ 'KeyType', 'Kind', 'Name', + 'ResourceIdentityType', + 'SigningKey', ] diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_azure_maps_management_client_enums.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_azure_maps_management_client_enums.py index cbd8bf5f1d281..9d8c95a688fa1 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_azure_maps_management_client_enums.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_azure_maps_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,24 +20,40 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether the operation refers to the primary or secondary key. """ PRIMARY = "primary" SECONDARY = "secondary" -class Kind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The Kind of the Maps Account. """ GEN1 = "Gen1" GEN2 = "Gen2" -class Name(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU, in standard format (such as S0). """ S0 = "S0" S1 = "S1" G2 = "G2" + +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class SigningKey(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The Map account key to use for signing. + """ + + PRIMARY_KEY = "primaryKey" + SECONDARY_KEY = "secondaryKey" diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_models.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_models.py deleted file mode 100644 index 693213d7a0e08..0000000000000 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_models.py +++ /dev/null @@ -1,844 +0,0 @@ -# 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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -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 - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type 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, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class Creator(TrackedResource): - """An Azure resource which represents Maps Creator product and provides ability to manage private location data. - - 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 - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param properties: Required. The Creator resource properties. - :type properties: ~azure.mgmt.maps.models.CreatorProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'properties': {'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'}, - 'properties': {'key': 'properties', 'type': 'CreatorProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Creator, self).__init__(**kwargs) - self.properties = kwargs['properties'] - - -class CreatorList(msrest.serialization.Model): - """A list of Creator resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: a Creator account. - :vartype value: list[~azure.mgmt.maps.models.Creator] - :param next_link: URL client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Creator]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CreatorList, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class CreatorProperties(msrest.serialization.Model): - """Creator resource properties. - - 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 provisioning_state: The state of the resource provisioning, terminal states: Succeeded, - Failed, Canceled. - :vartype provisioning_state: str - :param storage_units: Required. The storage units to be allocated. Integer values from 1 to - 100, inclusive. - :type storage_units: int - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'storage_units': {'required': True, 'maximum': 100, 'minimum': 1}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'storage_units': {'key': 'storageUnits', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(CreatorProperties, self).__init__(**kwargs) - self.provisioning_state = None - self.storage_units = kwargs['storage_units'] - - -class CreatorUpdateParameters(msrest.serialization.Model): - """Parameters used to update an existing Creator resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 - characters and value no greater than 256 characters. - :type tags: dict[str, str] - :ivar provisioning_state: The state of the resource provisioning, terminal states: Succeeded, - Failed, Canceled. - :vartype provisioning_state: str - :param storage_units: The storage units to be allocated. Integer values from 1 to 100, - inclusive. - :type storage_units: int - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'storage_units': {'maximum': 100, 'minimum': 1}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'storage_units': {'key': 'properties.storageUnits', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(CreatorUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.provisioning_state = None - self.storage_units = kwargs.get('storage_units', None) - - -class Dimension(msrest.serialization.Model): - """Dimension of map account, for example API Category, Api Name, Result Type, and Response Code. - - :param name: Display name of dimension. - :type name: str - :param display_name: Display name of dimension. - :type display_name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Dimension, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: str - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.maps.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.maps.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.maps.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class MapsAccount(TrackedResource): - """An Azure resource which represents access to a suite of Maps REST APIs. - - 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 - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param sku: Required. The SKU of this account. - :type sku: ~azure.mgmt.maps.models.Sku - :param kind: Get or Set Kind property. Possible values include: "Gen1", "Gen2". Default value: - "Gen1". - :type kind: str or ~azure.mgmt.maps.models.Kind - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.maps.models.SystemData - :param properties: The map account properties. - :type properties: ~azure.mgmt.maps.models.MapsAccountProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'system_data': {'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'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'MapsAccountProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MapsAccount, self).__init__(**kwargs) - self.sku = kwargs['sku'] - self.kind = kwargs.get('kind', "Gen1") - self.system_data = None - self.properties = kwargs.get('properties', None) - - -class MapsAccountKeys(msrest.serialization.Model): - """The set of keys which can be used to access the Maps REST APIs. Two keys are provided for key rotation without interruption. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar primary_key_last_updated: The last updated date and time of the primary key. - :vartype primary_key_last_updated: str - :ivar primary_key: The primary key for accessing the Maps REST APIs. - :vartype primary_key: str - :ivar secondary_key: The secondary key for accessing the Maps REST APIs. - :vartype secondary_key: str - :ivar secondary_key_last_updated: The last updated date and time of the secondary key. - :vartype secondary_key_last_updated: str - """ - - _validation = { - 'primary_key_last_updated': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'secondary_key_last_updated': {'readonly': True}, - } - - _attribute_map = { - 'primary_key_last_updated': {'key': 'primaryKeyLastUpdated', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'secondary_key_last_updated': {'key': 'secondaryKeyLastUpdated', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MapsAccountKeys, self).__init__(**kwargs) - self.primary_key_last_updated = None - self.primary_key = None - self.secondary_key = None - self.secondary_key_last_updated = None - - -class MapsAccountProperties(msrest.serialization.Model): - """Additional Map account properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_id: A unique identifier for the maps account. - :vartype unique_id: str - :param disable_local_auth: Allows toggle functionality on Azure Policy to disable Azure Maps - local authentication support. This will disable Shared Keys authentication from any usage. - :type disable_local_auth: bool - :ivar provisioning_state: the state of the provisioning. - :vartype provisioning_state: str - """ - - _validation = { - 'unique_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'unique_id': {'key': 'uniqueId', 'type': 'str'}, - 'disable_local_auth': {'key': 'disableLocalAuth', 'type': 'bool'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MapsAccountProperties, self).__init__(**kwargs) - self.unique_id = None - self.disable_local_auth = kwargs.get('disable_local_auth', False) - self.provisioning_state = None - - -class MapsAccounts(msrest.serialization.Model): - """A list of Maps Accounts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: a Maps Account. - :vartype value: list[~azure.mgmt.maps.models.MapsAccount] - :param next_link: URL client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MapsAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MapsAccounts, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class MapsAccountUpdateParameters(msrest.serialization.Model): - """Parameters used to update an existing Maps Account. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 - characters and value no greater than 256 characters. - :type tags: dict[str, str] - :param kind: Get or Set Kind property. Possible values include: "Gen1", "Gen2". Default value: - "Gen1". - :type kind: str or ~azure.mgmt.maps.models.Kind - :param sku: The SKU of this account. - :type sku: ~azure.mgmt.maps.models.Sku - :ivar unique_id: A unique identifier for the maps account. - :vartype unique_id: str - :param disable_local_auth: Allows toggle functionality on Azure Policy to disable Azure Maps - local authentication support. This will disable Shared Keys authentication from any usage. - :type disable_local_auth: bool - :ivar provisioning_state: the state of the provisioning. - :vartype provisioning_state: str - """ - - _validation = { - 'unique_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'unique_id': {'key': 'properties.uniqueId', 'type': 'str'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MapsAccountUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.kind = kwargs.get('kind', "Gen1") - self.sku = kwargs.get('sku', None) - self.unique_id = None - self.disable_local_auth = kwargs.get('disable_local_auth', False) - self.provisioning_state = None - - -class MapsKeySpecification(msrest.serialization.Model): - """Whether the operation refers to the primary or secondary key. - - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. Whether the operation refers to the primary or secondary key. - Possible values include: "primary", "secondary". - :type key_type: str or ~azure.mgmt.maps.models.KeyType - """ - - _validation = { - 'key_type': {'required': True}, - } - - _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MapsKeySpecification, self).__init__(**kwargs) - self.key_type = kwargs['key_type'] - - -class MapsOperations(msrest.serialization.Model): - """The set of operations available for Maps. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An operation available for Maps. - :vartype value: list[~azure.mgmt.maps.models.OperationDetail] - :param next_link: URL client should use to fetch the next page (per server side paging). - It's null for now, added for future use. - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDetail]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MapsOperations, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class MetricSpecification(msrest.serialization.Model): - """Metric specification of operation. - - :param name: Name of metric specification. - :type name: str - :param display_name: Display name of metric specification. - :type display_name: str - :param display_description: Display description of metric specification. - :type display_description: str - :param unit: Unit could be Count. - :type unit: str - :param dimensions: Dimensions of map account. - :type dimensions: list[~azure.mgmt.maps.models.Dimension] - :param aggregation_type: Aggregation type could be Average. - :type aggregation_type: str - :param fill_gap_with_zero: The property to decide fill gap with zero or not. - :type fill_gap_with_zero: bool - :param category: The category this metric specification belong to, could be Capacity. - :type category: str - :param resource_id_dimension_name_override: Account Resource Id. - :type resource_id_dimension_name_override: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecification, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.dimensions = kwargs.get('dimensions', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - - -class OperationDetail(msrest.serialization.Model): - """Operation detail payload. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.maps.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: One property of operation, include metric specifications. - :type service_specification: ~azure.mgmt.maps.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDetail, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display payload. - - :param provider: Resource provider of the operation. - :type provider: str - :param resource: Resource of the operation. - :type resource: str - :param operation: Localized friendly name for the operation. - :type operation: str - :param description: Localized friendly description for the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class ServiceSpecification(msrest.serialization.Model): - """One property of operation, include metric specifications. - - :param metric_specifications: Metric specifications of operation. - :type metric_specifications: list[~azure.mgmt.maps.models.MetricSpecification] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Sku(msrest.serialization.Model): - """The SKU of the Maps Account. - - 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. - - :param name: Required. The name of the SKU, in standard format (such as S0). Possible values - include: "S0", "S1", "G2". - :type name: str or ~azure.mgmt.maps.models.Name - :ivar tier: Gets the sku tier. This is based on the SKU name. - :vartype tier: str - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.maps.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.maps.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_models_py3.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_models_py3.py index ec9c52a1acaf8..baceaae71ce20 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_models_py3.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/models/_models_py3.py @@ -15,6 +15,190 @@ from ._azure_maps_management_client_enums import * +class AccountSasParameters(msrest.serialization.Model): + """Parameters used to create an account Shared Access Signature (SAS) token. The REST API access control is provided by Azure Maps Role Based Access (RBAC) identity and access. + + All required parameters must be populated in order to send to Azure. + + :ivar signing_key: Required. The Map account key to use for signing. Possible values include: + "primaryKey", "secondaryKey". + :vartype signing_key: str or ~azure.mgmt.maps.models.SigningKey + :ivar principal_id: Required. The principal Id also known as the object Id of a User Assigned + Managed Identity currently assigned to the Map Account. To assign a Managed Identity of the + account, use operation Create or Update an assign a User Assigned Identity resource Id. + :vartype principal_id: str + :ivar regions: Optional, allows control of which region locations are permitted access to Azure + Maps REST APIs with the SAS token. Example: "eastus", "westus2". Omitting this parameter will + allow all region locations to be accessible. + :vartype regions: list[str] + :ivar max_rate_per_second: Required. Required parameter which represents the desired maximum + request per second to allowed for the given SAS token. This does not guarantee perfect accuracy + in measurements but provides application safe guards of abuse with eventual enforcement. + :vartype max_rate_per_second: int + :ivar start: Required. The date time offset of when the token validity begins. For example + "2017-05-24T10:42:03.1567373Z". + :vartype start: str + :ivar expiry: Required. The date time offset of when the token validity expires. For example + "2017-05-24T10:42:03.1567373Z". + :vartype expiry: str + """ + + _validation = { + 'signing_key': {'required': True}, + 'principal_id': {'required': True}, + 'max_rate_per_second': {'required': True, 'maximum': 500, 'minimum_ex': 0}, + 'start': {'required': True}, + 'expiry': {'required': True}, + } + + _attribute_map = { + 'signing_key': {'key': 'signingKey', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'regions': {'key': 'regions', 'type': '[str]'}, + 'max_rate_per_second': {'key': 'maxRatePerSecond', 'type': 'int'}, + 'start': {'key': 'start', 'type': 'str'}, + 'expiry': {'key': 'expiry', 'type': 'str'}, + } + + def __init__( + self, + *, + signing_key: Union[str, "SigningKey"], + principal_id: str, + max_rate_per_second: int = 500, + start: str, + expiry: str, + regions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword signing_key: Required. The Map account key to use for signing. Possible values + include: "primaryKey", "secondaryKey". + :paramtype signing_key: str or ~azure.mgmt.maps.models.SigningKey + :keyword principal_id: Required. The principal Id also known as the object Id of a User + Assigned Managed Identity currently assigned to the Map Account. To assign a Managed Identity + of the account, use operation Create or Update an assign a User Assigned Identity resource Id. + :paramtype principal_id: str + :keyword regions: Optional, allows control of which region locations are permitted access to + Azure Maps REST APIs with the SAS token. Example: "eastus", "westus2". Omitting this parameter + will allow all region locations to be accessible. + :paramtype regions: list[str] + :keyword max_rate_per_second: Required. Required parameter which represents the desired maximum + request per second to allowed for the given SAS token. This does not guarantee perfect accuracy + in measurements but provides application safe guards of abuse with eventual enforcement. + :paramtype max_rate_per_second: int + :keyword start: Required. The date time offset of when the token validity begins. For example + "2017-05-24T10:42:03.1567373Z". + :paramtype start: str + :keyword expiry: Required. The date time offset of when the token validity expires. For example + "2017-05-24T10:42:03.1567373Z". + :paramtype expiry: str + """ + super(AccountSasParameters, self).__init__(**kwargs) + self.signing_key = signing_key + self.principal_id = principal_id + self.regions = regions + self.max_rate_per_second = max_rate_per_second + self.start = start + self.expiry = expiry + + +class Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class CorsRule(msrest.serialization.Model): + """Specifies a CORS rule for the Map Account. + + All required parameters must be populated in order to send to Azure. + + :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin + domains that will be allowed via CORS, or "*" to allow all domains. + :vartype allowed_origins: list[str] + """ + + _validation = { + 'allowed_origins': {'required': True}, + } + + _attribute_map = { + 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, + } + + def __init__( + self, + *, + allowed_origins: List[str], + **kwargs + ): + """ + :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin + domains that will be allowed via CORS, or "*" to allow all domains. + :paramtype allowed_origins: list[str] + """ + super(CorsRule, self).__init__(**kwargs) + self.allowed_origins = allowed_origins + + +class CorsRules(msrest.serialization.Model): + """Sets the CORS rules. You can include up to five CorsRule elements in the request. + + :ivar cors_rules: The list of CORS rules. You can include up to five CorsRule elements in the + request. + :vartype cors_rules: list[~azure.mgmt.maps.models.CorsRule] + """ + + _validation = { + 'cors_rules': {'max_items': 5, 'min_items': 0}, + } + + _attribute_map = { + 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + } + + def __init__( + self, + *, + cors_rules: Optional[List["CorsRule"]] = None, + **kwargs + ): + """ + :keyword cors_rules: The list of CORS rules. You can include up to five CorsRule elements in + the request. + :paramtype cors_rules: list[~azure.mgmt.maps.models.CorsRule] + """ + super(CorsRules, self).__init__(**kwargs) + self.cors_rules = cors_rules + + class Resource(msrest.serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. @@ -46,6 +230,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -67,10 +253,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: 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 = { @@ -95,6 +281,12 @@ def __init__( 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 @@ -115,12 +307,14 @@ class Creator(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param properties: Required. The Creator resource properties. - :type properties: ~azure.mgmt.maps.models.CreatorProperties + :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 properties: Required. The Creator resource properties. + :vartype properties: ~azure.mgmt.maps.models.CreatorProperties + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.maps.models.SystemData """ _validation = { @@ -129,6 +323,7 @@ class Creator(TrackedResource): 'type': {'readonly': True}, 'location': {'required': True}, 'properties': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -138,6 +333,7 @@ class Creator(TrackedResource): 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, 'properties': {'key': 'properties', 'type': 'CreatorProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -148,8 +344,17 @@ def __init__( 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 + :keyword properties: Required. The Creator resource properties. + :paramtype properties: ~azure.mgmt.maps.models.CreatorProperties + """ super(Creator, self).__init__(tags=tags, location=location, **kwargs) self.properties = properties + self.system_data = None class CreatorList(msrest.serialization.Model): @@ -159,9 +364,9 @@ class CreatorList(msrest.serialization.Model): :ivar value: a Creator account. :vartype value: list[~azure.mgmt.maps.models.Creator] - :param next_link: URL client should use to fetch the next page (per server side paging). + :ivar next_link: URL client should use to fetch the next page (per server side paging). It's null for now, added for future use. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -179,6 +384,11 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ super(CreatorList, self).__init__(**kwargs) self.value = None self.next_link = next_link @@ -194,9 +404,9 @@ class CreatorProperties(msrest.serialization.Model): :ivar provisioning_state: The state of the resource provisioning, terminal states: Succeeded, Failed, Canceled. :vartype provisioning_state: str - :param storage_units: Required. The storage units to be allocated. Integer values from 1 to - 100, inclusive. - :type storage_units: int + :ivar storage_units: Required. The storage units to be allocated. Integer values from 1 to 100, + inclusive. + :vartype storage_units: int """ _validation = { @@ -215,6 +425,11 @@ def __init__( storage_units: int, **kwargs ): + """ + :keyword storage_units: Required. The storage units to be allocated. Integer values from 1 to + 100, inclusive. + :paramtype storage_units: int + """ super(CreatorProperties, self).__init__(**kwargs) self.provisioning_state = None self.storage_units = storage_units @@ -225,17 +440,17 @@ class CreatorUpdateParameters(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. - :type tags: dict[str, str] + :vartype tags: dict[str, str] :ivar provisioning_state: The state of the resource provisioning, terminal states: Succeeded, Failed, Canceled. :vartype provisioning_state: str - :param storage_units: The storage units to be allocated. Integer values from 1 to 100, + :ivar storage_units: The storage units to be allocated. Integer values from 1 to 100, inclusive. - :type storage_units: int + :vartype storage_units: int """ _validation = { @@ -256,6 +471,16 @@ def __init__( storage_units: Optional[int] = None, **kwargs ): + """ + :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the + resource. These tags can be used in viewing and grouping this resource (across resource + groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no + greater than 128 characters and value no greater than 256 characters. + :paramtype tags: dict[str, str] + :keyword storage_units: The storage units to be allocated. Integer values from 1 to 100, + inclusive. + :paramtype storage_units: int + """ super(CreatorUpdateParameters, self).__init__(**kwargs) self.tags = tags self.provisioning_state = None @@ -265,15 +490,27 @@ def __init__( class Dimension(msrest.serialization.Model): """Dimension of map account, for example API Category, Api Name, Result Type, and Response Code. - :param name: Display name of dimension. - :type name: str - :param display_name: Display name of dimension. - :type display_name: str + :ivar name: Display name of dimension. + :vartype name: str + :ivar display_name: Display name of dimension. + :vartype display_name: str + :ivar internal_name: Internal name of the dimension. + :vartype internal_name: str + :ivar internal_metric_name: Internal metric name of the dimension. + :vartype internal_metric_name: str + :ivar source_mdm_namespace: Source Mdm Namespace of the dimension. + :vartype source_mdm_namespace: str + :ivar to_be_exported_to_shoebox: Flag to indicate exporting to Azure Monitor. + :vartype to_be_exported_to_shoebox: bool """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, + 'internal_name': {'key': 'internalName', 'type': 'str'}, + 'internal_metric_name': {'key': 'internalMetricName', 'type': 'str'}, + 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + 'to_be_exported_to_shoebox': {'key': 'toBeExportedToShoebox', 'type': 'bool'}, } def __init__( @@ -281,11 +518,33 @@ def __init__( *, name: Optional[str] = None, display_name: Optional[str] = None, + internal_name: Optional[str] = None, + internal_metric_name: Optional[str] = None, + source_mdm_namespace: Optional[str] = None, + to_be_exported_to_shoebox: Optional[bool] = None, **kwargs ): + """ + :keyword name: Display name of dimension. + :paramtype name: str + :keyword display_name: Display name of dimension. + :paramtype display_name: str + :keyword internal_name: Internal name of the dimension. + :paramtype internal_name: str + :keyword internal_metric_name: Internal metric name of the dimension. + :paramtype internal_metric_name: str + :keyword source_mdm_namespace: Source Mdm Namespace of the dimension. + :paramtype source_mdm_namespace: str + :keyword to_be_exported_to_shoebox: Flag to indicate exporting to Azure Monitor. + :paramtype to_be_exported_to_shoebox: bool + """ super(Dimension, self).__init__(**kwargs) self.name = name self.display_name = display_name + self.internal_name = internal_name + self.internal_metric_name = internal_metric_name + self.source_mdm_namespace = source_mdm_namespace + self.to_be_exported_to_shoebox = to_be_exported_to_shoebox class ErrorAdditionalInfo(msrest.serialization.Model): @@ -296,7 +555,7 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: str + :vartype info: any """ _validation = { @@ -306,13 +565,15 @@ class ErrorAdditionalInfo(msrest.serialization.Model): _attribute_map = { 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, } def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -355,6 +616,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -366,8 +629,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.maps.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.maps.models.ErrorDetail """ _attribute_map = { @@ -380,10 +643,110 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.maps.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error +class LinkedResource(msrest.serialization.Model): + """Linked resource is reference to a resource deployed in an Azure subscription, add the linked resource ``uniqueName`` value as an optional parameter for operations on Azure Maps Geospatial REST APIs. + + All required parameters must be populated in order to send to Azure. + + :ivar unique_name: Required. A provided name which uniquely identifies the linked resource. + :vartype unique_name: str + :ivar id: Required. ARM resource id in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/accounts/{storageName}'. + :vartype id: str + """ + + _validation = { + 'unique_name': {'required': True}, + 'id': {'required': True}, + } + + _attribute_map = { + 'unique_name': {'key': 'uniqueName', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + unique_name: str, + id: str, + **kwargs + ): + """ + :keyword unique_name: Required. A provided name which uniquely identifies the linked resource. + :paramtype unique_name: str + :keyword id: Required. ARM resource id in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/accounts/{storageName}'. + :paramtype id: str + """ + super(LinkedResource, self).__init__(**kwargs) + self.unique_name = unique_name + self.id = id + + +class ManagedServiceIdentity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.maps.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.maps.models.Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.maps.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.maps.models.Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties] + """ + super(ManagedServiceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + class MapsAccount(TrackedResource): """An Azure resource which represents access to a suite of Maps REST APIs. @@ -399,19 +762,21 @@ class MapsAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param sku: Required. The SKU of this account. - :type sku: ~azure.mgmt.maps.models.Sku - :param kind: Get or Set Kind property. Possible values include: "Gen1", "Gen2". Default value: + :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 sku: Required. The SKU of this account. + :vartype sku: ~azure.mgmt.maps.models.Sku + :ivar kind: Get or Set Kind property. Possible values include: "Gen1", "Gen2". Default value: "Gen1". - :type kind: str or ~azure.mgmt.maps.models.Kind + :vartype kind: str or ~azure.mgmt.maps.models.Kind :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.maps.models.SystemData - :param properties: The map account properties. - :type properties: ~azure.mgmt.maps.models.MapsAccountProperties + :ivar identity: Sets the identity property for maps account. + :vartype identity: ~azure.mgmt.maps.models.ManagedServiceIdentity + :ivar properties: The map account properties. + :vartype properties: ~azure.mgmt.maps.models.MapsAccountProperties """ _validation = { @@ -432,6 +797,7 @@ class MapsAccount(TrackedResource): 'sku': {'key': 'sku', 'type': 'Sku'}, 'kind': {'key': 'kind', 'type': 'str'}, 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, 'properties': {'key': 'properties', 'type': 'MapsAccountProperties'}, } @@ -442,13 +808,30 @@ def __init__( sku: "Sku", tags: Optional[Dict[str, str]] = None, kind: Optional[Union[str, "Kind"]] = "Gen1", + identity: Optional["ManagedServiceIdentity"] = None, properties: Optional["MapsAccountProperties"] = 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 + :keyword sku: Required. The SKU of this account. + :paramtype sku: ~azure.mgmt.maps.models.Sku + :keyword kind: Get or Set Kind property. Possible values include: "Gen1", "Gen2". Default + value: "Gen1". + :paramtype kind: str or ~azure.mgmt.maps.models.Kind + :keyword identity: Sets the identity property for maps account. + :paramtype identity: ~azure.mgmt.maps.models.ManagedServiceIdentity + :keyword properties: The map account properties. + :paramtype properties: ~azure.mgmt.maps.models.MapsAccountProperties + """ super(MapsAccount, self).__init__(tags=tags, location=location, **kwargs) self.sku = sku self.kind = kind self.system_data = None + self.identity = identity self.properties = properties @@ -485,6 +868,8 @@ def __init__( self, **kwargs ): + """ + """ super(MapsAccountKeys, self).__init__(**kwargs) self.primary_key_last_updated = None self.primary_key = None @@ -499,34 +884,60 @@ class MapsAccountProperties(msrest.serialization.Model): :ivar unique_id: A unique identifier for the maps account. :vartype unique_id: str - :param disable_local_auth: Allows toggle functionality on Azure Policy to disable Azure Maps + :ivar disable_local_auth: Allows toggle functionality on Azure Policy to disable Azure Maps local authentication support. This will disable Shared Keys authentication from any usage. - :type disable_local_auth: bool - :ivar provisioning_state: the state of the provisioning. + :vartype disable_local_auth: bool + :ivar provisioning_state: The provisioning state of the Map account resource. :vartype provisioning_state: str + :ivar linked_resources: Sets the resources to be used for Managed Identities based operations + for the Map account resource. + :vartype linked_resources: list[~azure.mgmt.maps.models.LinkedResource] + :ivar cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :vartype cors: ~azure.mgmt.maps.models.CorsRules """ _validation = { 'unique_id': {'readonly': True}, 'provisioning_state': {'readonly': True}, + 'linked_resources': {'max_items': 10, 'min_items': 0}, } _attribute_map = { 'unique_id': {'key': 'uniqueId', 'type': 'str'}, 'disable_local_auth': {'key': 'disableLocalAuth', 'type': 'bool'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'linked_resources': {'key': 'linkedResources', 'type': '[LinkedResource]'}, + 'cors': {'key': 'cors', 'type': 'CorsRules'}, } def __init__( self, *, disable_local_auth: Optional[bool] = False, + linked_resources: Optional[List["LinkedResource"]] = None, + cors: Optional["CorsRules"] = None, **kwargs ): + """ + :keyword disable_local_auth: Allows toggle functionality on Azure Policy to disable Azure Maps + local authentication support. This will disable Shared Keys authentication from any usage. + :paramtype disable_local_auth: bool + :keyword linked_resources: Sets the resources to be used for Managed Identities based + operations for the Map account resource. + :paramtype linked_resources: list[~azure.mgmt.maps.models.LinkedResource] + :keyword cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :paramtype cors: ~azure.mgmt.maps.models.CorsRules + """ super(MapsAccountProperties, self).__init__(**kwargs) self.unique_id = None self.disable_local_auth = disable_local_auth self.provisioning_state = None + self.linked_resources = linked_resources + self.cors = cors class MapsAccounts(msrest.serialization.Model): @@ -536,9 +947,9 @@ class MapsAccounts(msrest.serialization.Model): :ivar value: a Maps Account. :vartype value: list[~azure.mgmt.maps.models.MapsAccount] - :param next_link: URL client should use to fetch the next page (per server side paging). + :ivar next_link: URL client should use to fetch the next page (per server side paging). It's null for now, added for future use. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -556,47 +967,92 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ super(MapsAccounts, self).__init__(**kwargs) self.value = None self.next_link = next_link +class MapsAccountSasToken(msrest.serialization.Model): + """A new Sas token which can be used to access the Maps REST APIs and is controlled by the specified Managed identity permissions on Azure (IAM) Role Based Access Control. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar account_sas_token: The shared access signature access token. + :vartype account_sas_token: str + """ + + _validation = { + 'account_sas_token': {'readonly': True}, + } + + _attribute_map = { + 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(MapsAccountSasToken, self).__init__(**kwargs) + self.account_sas_token = None + + class MapsAccountUpdateParameters(msrest.serialization.Model): """Parameters used to update an existing Maps Account. Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. - :type tags: dict[str, str] - :param kind: Get or Set Kind property. Possible values include: "Gen1", "Gen2". Default value: + :vartype tags: dict[str, str] + :ivar kind: Get or Set Kind property. Possible values include: "Gen1", "Gen2". Default value: "Gen1". - :type kind: str or ~azure.mgmt.maps.models.Kind - :param sku: The SKU of this account. - :type sku: ~azure.mgmt.maps.models.Sku + :vartype kind: str or ~azure.mgmt.maps.models.Kind + :ivar sku: The SKU of this account. + :vartype sku: ~azure.mgmt.maps.models.Sku + :ivar identity: Sets the identity property for maps account. + :vartype identity: ~azure.mgmt.maps.models.ManagedServiceIdentity :ivar unique_id: A unique identifier for the maps account. :vartype unique_id: str - :param disable_local_auth: Allows toggle functionality on Azure Policy to disable Azure Maps + :ivar disable_local_auth: Allows toggle functionality on Azure Policy to disable Azure Maps local authentication support. This will disable Shared Keys authentication from any usage. - :type disable_local_auth: bool - :ivar provisioning_state: the state of the provisioning. + :vartype disable_local_auth: bool + :ivar provisioning_state: The provisioning state of the Map account resource. :vartype provisioning_state: str + :ivar linked_resources: Sets the resources to be used for Managed Identities based operations + for the Map account resource. + :vartype linked_resources: list[~azure.mgmt.maps.models.LinkedResource] + :ivar cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :vartype cors: ~azure.mgmt.maps.models.CorsRules """ _validation = { 'unique_id': {'readonly': True}, 'provisioning_state': {'readonly': True}, + 'linked_resources': {'max_items': 10, 'min_items': 0}, } _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, 'unique_id': {'key': 'properties.uniqueId', 'type': 'str'}, 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'linked_resources': {'key': 'properties.linkedResources', 'type': '[LinkedResource]'}, + 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, } def __init__( @@ -605,16 +1061,46 @@ def __init__( tags: Optional[Dict[str, str]] = None, kind: Optional[Union[str, "Kind"]] = "Gen1", sku: Optional["Sku"] = None, + identity: Optional["ManagedServiceIdentity"] = None, disable_local_auth: Optional[bool] = False, + linked_resources: Optional[List["LinkedResource"]] = None, + cors: Optional["CorsRules"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the + resource. These tags can be used in viewing and grouping this resource (across resource + groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no + greater than 128 characters and value no greater than 256 characters. + :paramtype tags: dict[str, str] + :keyword kind: Get or Set Kind property. Possible values include: "Gen1", "Gen2". Default + value: "Gen1". + :paramtype kind: str or ~azure.mgmt.maps.models.Kind + :keyword sku: The SKU of this account. + :paramtype sku: ~azure.mgmt.maps.models.Sku + :keyword identity: Sets the identity property for maps account. + :paramtype identity: ~azure.mgmt.maps.models.ManagedServiceIdentity + :keyword disable_local_auth: Allows toggle functionality on Azure Policy to disable Azure Maps + local authentication support. This will disable Shared Keys authentication from any usage. + :paramtype disable_local_auth: bool + :keyword linked_resources: Sets the resources to be used for Managed Identities based + operations for the Map account resource. + :paramtype linked_resources: list[~azure.mgmt.maps.models.LinkedResource] + :keyword cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :paramtype cors: ~azure.mgmt.maps.models.CorsRules + """ super(MapsAccountUpdateParameters, self).__init__(**kwargs) self.tags = tags self.kind = kind self.sku = sku + self.identity = identity self.unique_id = None self.disable_local_auth = disable_local_auth self.provisioning_state = None + self.linked_resources = linked_resources + self.cors = cors class MapsKeySpecification(msrest.serialization.Model): @@ -622,9 +1108,9 @@ class MapsKeySpecification(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_type: Required. Whether the operation refers to the primary or secondary key. + :ivar key_type: Required. Whether the operation refers to the primary or secondary key. Possible values include: "primary", "secondary". - :type key_type: str or ~azure.mgmt.maps.models.KeyType + :vartype key_type: str or ~azure.mgmt.maps.models.KeyType """ _validation = { @@ -641,6 +1127,11 @@ def __init__( key_type: Union[str, "KeyType"], **kwargs ): + """ + :keyword key_type: Required. Whether the operation refers to the primary or secondary key. + Possible values include: "primary", "secondary". + :paramtype key_type: str or ~azure.mgmt.maps.models.KeyType + """ super(MapsKeySpecification, self).__init__(**kwargs) self.key_type = key_type @@ -652,9 +1143,9 @@ class MapsOperations(msrest.serialization.Model): :ivar value: An operation available for Maps. :vartype value: list[~azure.mgmt.maps.models.OperationDetail] - :param next_link: URL client should use to fetch the next page (per server side paging). + :ivar next_link: URL client should use to fetch the next page (per server side paging). It's null for now, added for future use. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -672,6 +1163,11 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ super(MapsOperations, self).__init__(**kwargs) self.value = None self.next_link = next_link @@ -680,24 +1176,28 @@ def __init__( class MetricSpecification(msrest.serialization.Model): """Metric specification of operation. - :param name: Name of metric specification. - :type name: str - :param display_name: Display name of metric specification. - :type display_name: str - :param display_description: Display description of metric specification. - :type display_description: str - :param unit: Unit could be Count. - :type unit: str - :param dimensions: Dimensions of map account. - :type dimensions: list[~azure.mgmt.maps.models.Dimension] - :param aggregation_type: Aggregation type could be Average. - :type aggregation_type: str - :param fill_gap_with_zero: The property to decide fill gap with zero or not. - :type fill_gap_with_zero: bool - :param category: The category this metric specification belong to, could be Capacity. - :type category: str - :param resource_id_dimension_name_override: Account Resource Id. - :type resource_id_dimension_name_override: str + :ivar name: Name of metric specification. + :vartype name: str + :ivar display_name: Display name of metric specification. + :vartype display_name: str + :ivar display_description: Display description of metric specification. + :vartype display_description: str + :ivar unit: Unit could be Count. + :vartype unit: str + :ivar dimensions: Dimensions of map account. + :vartype dimensions: list[~azure.mgmt.maps.models.Dimension] + :ivar aggregation_type: Aggregation type could be Average. + :vartype aggregation_type: str + :ivar fill_gap_with_zero: The property to decide fill gap with zero or not. + :vartype fill_gap_with_zero: bool + :ivar category: The category this metric specification belong to, could be Capacity. + :vartype category: str + :ivar resource_id_dimension_name_override: Account Resource Id. + :vartype resource_id_dimension_name_override: str + :ivar source_mdm_account: Source metrics account. + :vartype source_mdm_account: str + :ivar internal_metric_name: Internal metric name. + :vartype internal_metric_name: str """ _attribute_map = { @@ -710,6 +1210,8 @@ class MetricSpecification(msrest.serialization.Model): 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, 'category': {'key': 'category', 'type': 'str'}, 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + 'source_mdm_account': {'key': 'sourceMdmAccount', 'type': 'str'}, + 'internal_metric_name': {'key': 'internalMetricName', 'type': 'str'}, } def __init__( @@ -724,8 +1226,34 @@ def __init__( fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, resource_id_dimension_name_override: Optional[str] = None, + source_mdm_account: Optional[str] = None, + internal_metric_name: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of metric specification. + :paramtype name: str + :keyword display_name: Display name of metric specification. + :paramtype display_name: str + :keyword display_description: Display description of metric specification. + :paramtype display_description: str + :keyword unit: Unit could be Count. + :paramtype unit: str + :keyword dimensions: Dimensions of map account. + :paramtype dimensions: list[~azure.mgmt.maps.models.Dimension] + :keyword aggregation_type: Aggregation type could be Average. + :paramtype aggregation_type: str + :keyword fill_gap_with_zero: The property to decide fill gap with zero or not. + :paramtype fill_gap_with_zero: bool + :keyword category: The category this metric specification belong to, could be Capacity. + :paramtype category: str + :keyword resource_id_dimension_name_override: Account Resource Id. + :paramtype resource_id_dimension_name_override: str + :keyword source_mdm_account: Source metrics account. + :paramtype source_mdm_account: str + :keyword internal_metric_name: Internal metric name. + :paramtype internal_metric_name: str + """ super(MetricSpecification, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -736,21 +1264,23 @@ def __init__( self.fill_gap_with_zero = fill_gap_with_zero self.category = category self.resource_id_dimension_name_override = resource_id_dimension_name_override + self.source_mdm_account = source_mdm_account + self.internal_metric_name = internal_metric_name class OperationDetail(msrest.serialization.Model): """Operation detail payload. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.maps.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: One property of operation, include metric specifications. - :type service_specification: ~azure.mgmt.maps.models.ServiceSpecification + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.maps.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar service_specification: One property of operation, include metric specifications. + :vartype service_specification: ~azure.mgmt.maps.models.ServiceSpecification """ _attribute_map = { @@ -771,6 +1301,18 @@ def __init__( service_specification: Optional["ServiceSpecification"] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display of the operation. + :paramtype display: ~azure.mgmt.maps.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword service_specification: One property of operation, include metric specifications. + :paramtype service_specification: ~azure.mgmt.maps.models.ServiceSpecification + """ super(OperationDetail, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -782,14 +1324,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Operation display payload. - :param provider: Resource provider of the operation. - :type provider: str - :param resource: Resource of the operation. - :type resource: str - :param operation: Localized friendly name for the operation. - :type operation: str - :param description: Localized friendly description for the operation. - :type description: str + :ivar provider: Resource provider of the operation. + :vartype provider: str + :ivar resource: Resource of the operation. + :vartype resource: str + :ivar operation: Localized friendly name for the operation. + :vartype operation: str + :ivar description: Localized friendly description for the operation. + :vartype description: str """ _attribute_map = { @@ -808,6 +1350,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Resource provider of the operation. + :paramtype provider: str + :keyword resource: Resource of the operation. + :paramtype resource: str + :keyword operation: Localized friendly name for the operation. + :paramtype operation: str + :keyword description: Localized friendly description for the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -818,8 +1370,8 @@ def __init__( class ServiceSpecification(msrest.serialization.Model): """One property of operation, include metric specifications. - :param metric_specifications: Metric specifications of operation. - :type metric_specifications: list[~azure.mgmt.maps.models.MetricSpecification] + :ivar metric_specifications: Metric specifications of operation. + :vartype metric_specifications: list[~azure.mgmt.maps.models.MetricSpecification] """ _attribute_map = { @@ -832,6 +1384,10 @@ def __init__( metric_specifications: Optional[List["MetricSpecification"]] = None, **kwargs ): + """ + :keyword metric_specifications: Metric specifications of operation. + :paramtype metric_specifications: list[~azure.mgmt.maps.models.MetricSpecification] + """ super(ServiceSpecification, self).__init__(**kwargs) self.metric_specifications = metric_specifications @@ -843,9 +1399,9 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU, in standard format (such as S0). Possible values + :ivar name: Required. The name of the SKU, in standard format (such as S0). Possible values include: "S0", "S1", "G2". - :type name: str or ~azure.mgmt.maps.models.Name + :vartype name: str or ~azure.mgmt.maps.models.Name :ivar tier: Gets the sku tier. This is based on the SKU name. :vartype tier: str """ @@ -866,6 +1422,11 @@ def __init__( name: Union[str, "Name"], **kwargs ): + """ + :keyword name: Required. The name of the SKU, in standard format (such as S0). Possible values + include: "S0", "S1", "G2". + :paramtype name: str or ~azure.mgmt.maps.models.Name + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = None @@ -874,20 +1435,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.maps.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.maps.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.maps.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~azure.mgmt.maps.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -910,6 +1471,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.maps.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.maps.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_accounts_operations.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_accounts_operations.py index 1884423c9463a..7d7d13f8444f1 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_accounts_operations.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_accounts_operations.py @@ -5,23 +5,371 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_create_or_update_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_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, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_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_delete_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_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 + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_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_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Maps/accounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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_sas_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listSas') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listKeys') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/regenerateKey') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class AccountsOperations(object): """AccountsOperations operations. @@ -45,14 +393,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - account_name, # type: str - maps_account, # type: "_models.MapsAccount" - **kwargs # type: Any - ): - # type: (...) -> "_models.MapsAccount" + resource_group_name: str, + account_name: str, + maps_account: "_models.MapsAccount", + **kwargs: Any + ) -> "_models.MapsAccount": """Create or update a Maps Account. A Maps Account holds the keys which allow access to the Maps REST APIs. @@ -72,38 +420,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(maps_account, 'MapsAccount') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(maps_account, 'MapsAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -116,16 +454,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - account_name, # type: str - maps_account_update_parameters, # type: "_models.MapsAccountUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.MapsAccount" + resource_group_name: str, + account_name: str, + maps_account_update_parameters: "_models.MapsAccountUpdateParameters", + **kwargs: Any + ) -> "_models.MapsAccount": """Updates a Maps Account. Only a subset of the parameters may be updated after creation, such as Sku, Tags, Properties. @@ -145,38 +485,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(maps_account_update_parameters, 'MapsAccountUpdateParameters') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(maps_account_update_parameters, 'MapsAccountUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MapsAccount', pipeline_response) @@ -185,15 +515,17 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: """Delete a Maps Account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -210,33 +542,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -244,13 +566,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MapsAccount" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.MapsAccount": """Get a Maps Account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -267,33 +590,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MapsAccount', pipeline_response) @@ -302,14 +615,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MapsAccounts"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.MapsAccounts"]: """Get all Maps Accounts in a Resource Group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -324,35 +639,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MapsAccounts', pipeline_response) + deserialized = self._deserialize("MapsAccounts", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -365,22 +676,23 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MapsAccounts"] + **kwargs: Any + ) -> Iterable["_models.MapsAccounts"]: """Get all Maps Accounts in a Subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -393,34 +705,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MapsAccounts', pipeline_response) + deserialized = self._deserialize("MapsAccounts", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -433,24 +740,94 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maps/accounts'} # type: ignore + @distributed_trace + def list_sas( + self, + resource_group_name: str, + account_name: str, + maps_account_sas_parameters: "_models.AccountSasParameters", + **kwargs: Any + ) -> "_models.MapsAccountSasToken": + """Create and list an account shared access signature token. Use this SAS token for authentication + to Azure Maps REST APIs through various Azure Maps SDKs. As prerequisite to create a SAS Token. + + Prerequisites: + + + #. Create or have an existing User Assigned Managed Identity in the same Azure region as the + account. + #. Create or update an Azure Map account with the same Azure region as the User Assigned + Managed Identity is placed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the Maps Account. + :type account_name: str + :param maps_account_sas_parameters: The updated parameters for the Maps Account. + :type maps_account_sas_parameters: ~azure.mgmt.maps.models.AccountSasParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MapsAccountSasToken, or the result of cls(response) + :rtype: ~azure.mgmt.maps.models.MapsAccountSasToken + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MapsAccountSasToken"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(maps_account_sas_parameters, 'AccountSasParameters') + + request = build_list_sas_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self.list_sas.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MapsAccountSasToken', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listSas'} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MapsAccountKeys" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.MapsAccountKeys": """Get the keys to use with the Maps APIs. A key is used to authenticate and authorize access to the Maps REST APIs. Only one key is needed at a time; two are given to provide seamless key regeneration. @@ -469,33 +846,23 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MapsAccountKeys', pipeline_response) @@ -504,16 +871,18 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listKeys'} # type: ignore + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - account_name, # type: str - key_specification, # type: "_models.MapsKeySpecification" - **kwargs # type: Any - ): - # type: (...) -> "_models.MapsAccountKeys" + resource_group_name: str, + account_name: str, + key_specification: "_models.MapsKeySpecification", + **kwargs: Any + ) -> "_models.MapsAccountKeys": """Regenerate either the primary or secondary key for use with the Maps APIs. The old key will stop working immediately. @@ -533,38 +902,28 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(key_specification, 'MapsKeySpecification') + + request = build_regenerate_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(key_specification, 'MapsKeySpecification') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MapsAccountKeys', pipeline_response) @@ -573,4 +932,6 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized + regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/regenerateKey'} # type: ignore + diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_creators_operations.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_creators_operations.py index d755d7c72ccb9..c37650eae3171 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_creators_operations.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_creators_operations.py @@ -5,23 +5,227 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_account_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + creator_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "creatorName": _SERIALIZER.url("creator_name", creator_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, + account_name: str, + creator_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "creatorName": _SERIALIZER.url("creator_name", creator_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_delete_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + creator_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "creatorName": _SERIALIZER.url("creator_name", creator_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 + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + account_name: str, + creator_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "creatorName": _SERIALIZER.url("creator_name", creator_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 + ) class CreatorsOperations(object): """CreatorsOperations operations. @@ -45,13 +249,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_account( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CreatorList"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.CreatorList"]: """Get all Creator instances for an Azure Maps Account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -68,36 +272,33 @@ def list_by_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=self.list_by_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CreatorList', pipeline_response) + deserialized = self._deserialize("CreatorList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,26 +311,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators'} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - account_name, # type: str - creator_name, # type: str - creator_resource, # type: "_models.Creator" - **kwargs # type: Any - ): - # type: (...) -> "_models.Creator" + resource_group_name: str, + account_name: str, + creator_name: str, + creator_resource: "_models.Creator", + **kwargs: Any + ) -> "_models.Creator": """Create or update a Maps Creator resource. Creator resource will manage Azure resources required to populate a custom set of mapping data. It requires an account to exist before it can be created. @@ -152,39 +354,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'creatorName': self._serialize.url("creator_name", creator_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(creator_resource, 'Creator') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + creator_name=creator_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(creator_resource, 'Creator') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -197,17 +389,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - account_name, # type: str - creator_name, # type: str - creator_update_parameters, # type: "_models.CreatorUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Creator" + resource_group_name: str, + account_name: str, + creator_name: str, + creator_update_parameters: "_models.CreatorUpdateParameters", + **kwargs: Any + ) -> "_models.Creator": """Updates the Maps Creator resource. Only a subset of the parameters may be updated after creation, such as Tags. @@ -229,39 +423,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'creatorName': self._serialize.url("creator_name", creator_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(creator_update_parameters, 'CreatorUpdateParameters') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + creator_name=creator_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(creator_update_parameters, 'CreatorUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Creator', pipeline_response) @@ -270,16 +454,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - account_name, # type: str - creator_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + creator_name: str, + **kwargs: Any + ) -> None: """Delete a Maps Creator resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -298,34 +484,24 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'creatorName': self._serialize.url("creator_name", creator_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + creator_name=creator_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -333,14 +509,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - creator_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Creator" + resource_group_name: str, + account_name: str, + creator_name: str, + **kwargs: Any + ) -> "_models.Creator": """Get a Maps Creator resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -359,34 +536,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'creatorName': self._serialize.url("creator_name", creator_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + account_name=account_name, + creator_name=creator_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Creator', pipeline_response) @@ -395,4 +562,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/creators/{creatorName}'} # type: ignore + diff --git a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_maps_operations.py b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_maps_operations.py index 3671d70f0bb0a..a86747294d54c 100644 --- a/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_maps_operations.py +++ b/sdk/maps/azure-mgmt-maps/azure/mgmt/maps/operations/_maps_operations.py @@ -5,23 +5,81 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_operations_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Maps/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 + ) + + +def build_list_subscription_operations_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Maps/operations') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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 MapsOperations(object): """MapsOperations operations. @@ -45,11 +103,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_operations( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MapsOperations"] + **kwargs: Any + ) -> Iterable["_models.MapsOperations"]: """List operations available for the Maps Resource Provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +120,27 @@ def list_operations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_operations.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_operations_request( + template_url=self.list_operations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_operations_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MapsOperations', pipeline_response) + deserialized = self._deserialize("MapsOperations", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,13 +153,78 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_operations.metadata = {'url': '/providers/Microsoft.Maps/operations'} # type: ignore + + @distributed_trace + def list_subscription_operations( + self, + **kwargs: Any + ) -> Iterable["_models.MapsOperations"]: + """List operations available for the Maps Resource Provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MapsOperations or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maps.models.MapsOperations] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MapsOperations"] + 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_subscription_operations_request( + subscription_id=self._config.subscription_id, + template_url=self.list_subscription_operations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_subscription_operations_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MapsOperations", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_subscription_operations.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maps/operations'} # type: ignore