From daa34acb3de99c6a0a535bd44447d2aff0eb2385 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 15 Mar 2022 04:37:18 +0000 Subject: [PATCH] CodeGen from PR 18230 in Azure/azure-rest-api-specs Merge e391ee627007d598e3fff71001858711d6db15f0 into 2abe647120f14bb145968a5543ead8ed51394498 --- .../azure-mgmt-powerbidedicated/_meta.json | 11 + .../azure/mgmt/powerbidedicated/__init__.py | 9 +- .../mgmt/powerbidedicated/_configuration.py | 19 +- .../mgmt/powerbidedicated/_metadata.json | 104 ++ .../azure/mgmt/powerbidedicated/_patch.py | 31 + .../powerbidedicated/_power_bi_dedicated.py | 80 +- .../azure/mgmt/powerbidedicated/_vendor.py | 27 + .../azure/mgmt/powerbidedicated/_version.py | 2 +- .../mgmt/powerbidedicated/aio/__init__.py | 5 + .../powerbidedicated/aio/_configuration.py | 6 +- .../azure/mgmt/powerbidedicated/aio/_patch.py | 31 + .../aio/_power_bi_dedicated.py | 72 +- .../_auto_scale_vcores_operations.py | 272 ++-- .../aio/operations/_capacities_operations.py | 589 ++++----- .../aio/operations/_operations.py | 49 +- .../mgmt/powerbidedicated/models/__init__.py | 88 +- .../mgmt/powerbidedicated/models/_models.py | 798 ------------ .../powerbidedicated/models/_models_py3.py | 698 +++++++++-- .../models/_power_bi_dedicated_enums.py | 37 +- .../_auto_scale_vcores_operations.py | 546 +++++--- .../operations/_capacities_operations.py | 1099 +++++++++++------ .../operations/_operations.py | 85 +- 22 files changed, 2484 insertions(+), 2174 deletions(-) create mode 100644 sdk/powerbidedicated/azure-mgmt-powerbidedicated/_meta.json create mode 100644 sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_metadata.json create mode 100644 sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_patch.py create mode 100644 sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_vendor.py create mode 100644 sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_patch.py delete mode 100644 sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_models.py diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/_meta.json b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/_meta.json new file mode 100644 index 0000000000000..ff88afe14e323 --- /dev/null +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "85eb3e7dbe23e025b9c838bef309f11a05768f10", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/powerbidedicated/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/powerbidedicated/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/__init__.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/__init__.py index 85242d086108f..7edf17a479d81 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/__init__.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PowerBIDedicated'] -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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_configuration.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_configuration.py index e6d5726d4e102..220c05b18e83a 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_configuration.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_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,16 +33,15 @@ class PowerBIDedicatedConfiguration(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(PowerBIDedicatedConfiguration, 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(PowerBIDedicatedConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_metadata.json b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_metadata.json new file mode 100644 index 0000000000000..33a632bf71bb0 --- /dev/null +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_metadata.json @@ -0,0 +1,104 @@ +{ + "chosen_version": "2021-01-01", + "total_api_version_list": ["2021-01-01"], + "client": { + "name": "PowerBIDedicated", + "filename": "_power_bi_dedicated", + "description": "PowerBI Dedicated Web API provides a RESTful set of web services that enables users to create, retrieve, update, and delete Power BI dedicated capacities.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "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\": [\"PowerBIDedicatedConfiguration\"]}}, \"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\": [\"PowerBIDedicatedConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "A unique identifier for a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "A unique identifier for a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "capacities": "CapacitiesOperations", + "operations": "Operations", + "auto_scale_vcores": "AutoScaleVCoresOperations" + } +} \ No newline at end of file diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_patch.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_power_bi_dedicated.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_power_bi_dedicated.py index 4290021c67ccb..2c972c6a121e5 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_power_bi_dedicated.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_power_bi_dedicated.py @@ -6,25 +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 PowerBIDedicatedConfiguration +from .operations import AutoScaleVCoresOperations, CapacitiesOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import PowerBIDedicatedConfiguration -from .operations import CapacitiesOperations -from .operations import Operations -from .operations import AutoScaleVCoresOperations -from . import models - - -class PowerBIDedicated(object): +class PowerBIDedicated: """PowerBI Dedicated Web API provides a RESTful set of web services that enables users to create, retrieve, update, and delete Power BI dedicated capacities. :ivar capacities: CapacitiesOperations operations @@ -35,36 +32,59 @@ class PowerBIDedicated(object): :vartype auto_scale_vcores: azure.mgmt.powerbidedicated.operations.AutoScaleVCoresOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: A unique identifier for a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: A unique identifier for a Microsoft Azure subscription. The + subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ 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 = PowerBIDedicatedConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = PowerBIDedicatedConfiguration(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.capacities = CapacitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.auto_scale_vcores = AutoScaleVCoresOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ - self.capacities = CapacitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.auto_scale_vcores = AutoScaleVCoresOperations( - self._client, self._config, self._serialize, self._deserialize) + 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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_vendor.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_version.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_version.py index c47f66669f1bf..e5754a47ce68f 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_version.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/__init__.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/__init__.py index 7b60751482fd5..65d41a81e1763 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/__init__.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/__init__.py @@ -8,3 +8,8 @@ from ._power_bi_dedicated import PowerBIDedicated __all__ = ['PowerBIDedicated'] + +# `._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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_configuration.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_configuration.py index dffbc7ec413e5..dbdcf4aca19b1 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_configuration.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/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,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PowerBIDedicatedConfiguration, 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(PowerBIDedicatedConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_patch.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_power_bi_dedicated.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_power_bi_dedicated.py index c104e73844194..d984764825e27 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_power_bi_dedicated.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/_power_bi_dedicated.py @@ -6,23 +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.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PowerBIDedicatedConfiguration +from .operations import AutoScaleVCoresOperations, CapacitiesOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PowerBIDedicatedConfiguration -from .operations import CapacitiesOperations -from .operations import Operations -from .operations import AutoScaleVCoresOperations -from .. import models - - -class PowerBIDedicated(object): +class PowerBIDedicated: """PowerBI Dedicated Web API provides a RESTful set of web services that enables users to create, retrieve, update, and delete Power BI dedicated capacities. :ivar capacities: CapacitiesOperations operations @@ -30,38 +29,63 @@ class PowerBIDedicated(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.powerbidedicated.aio.operations.Operations :ivar auto_scale_vcores: AutoScaleVCoresOperations operations - :vartype auto_scale_vcores: azure.mgmt.powerbidedicated.aio.operations.AutoScaleVCoresOperations + :vartype auto_scale_vcores: + azure.mgmt.powerbidedicated.aio.operations.AutoScaleVCoresOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: A unique identifier for a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: A unique identifier for a Microsoft Azure subscription. The + subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ 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 = PowerBIDedicatedConfiguration(credential, subscription_id, **kwargs) + self._config = PowerBIDedicatedConfiguration(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.capacities = CapacitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.auto_scale_vcores = AutoScaleVCoresOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ - self.capacities = CapacitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.auto_scale_vcores = AutoScaleVCoresOperations( - self._client, self._config, self._serialize, self._deserialize) + 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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_auto_scale_vcores_operations.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_auto_scale_vcores_operations.py index 971a0f8af7ff3..c6416f1824dac 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_auto_scale_vcores_operations.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_auto_scale_vcores_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._auto_scale_vcores_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, vcore_name: str, - **kwargs + **kwargs: Any ) -> "_models.AutoScaleVCore": """Gets details about the specified auto scale v-core. @@ -66,33 +72,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vcoreName': self._serialize.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), - } - 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, + vcore_name=vcore_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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoScaleVCore', pipeline_response) @@ -101,14 +97,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}'} # type: ignore + + @distributed_trace_async async def create( self, resource_group_name: str, vcore_name: str, v_core_parameters: "_models.AutoScaleVCore", - **kwargs + **kwargs: Any ) -> "_models.AutoScaleVCore": """Provisions the specified auto scale v-core based on the configuration specified in the request. @@ -131,38 +130,28 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vcoreName': self._serialize.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), - } - 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(v_core_parameters, 'AutoScaleVCore') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcore_name=vcore_name, + content_type=content_type, + json=_json, + template_url=self.create.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(v_core_parameters, 'AutoScaleVCore') - 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._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('AutoScaleVCore', pipeline_response) @@ -171,13 +160,16 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, vcore_name: str, - **kwargs + **kwargs: Any ) -> None: """Deletes the specified auto scale v-core. @@ -198,33 +190,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vcoreName': self._serialize.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), - } - 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, + vcore_name=vcore_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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -232,12 +214,14 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, vcore_name: str, v_core_update_parameters: "_models.AutoScaleVCoreUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.AutoScaleVCore": """Updates the current state of the specified auto scale v-core. @@ -250,7 +234,8 @@ async def update( :type vcore_name: str :param v_core_update_parameters: Request object that contains the updated information for the auto scale v-core. - :type v_core_update_parameters: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreUpdateParameters + :type v_core_update_parameters: + ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoScaleVCore, or the result of cls(response) :rtype: ~azure.mgmt.powerbidedicated.models.AutoScaleVCore @@ -261,38 +246,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vcoreName': self._serialize.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), - } - 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(v_core_update_parameters, 'AutoScaleVCoreUpdateParameters') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcore_name=vcore_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(v_core_update_parameters, 'AutoScaleVCoreUpdateParameters') - 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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoScaleVCore', pipeline_response) @@ -301,12 +276,15 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.AutoScaleVCoreListResult"]: """Gets all the auto scale v-cores for the given resource group. @@ -315,8 +293,10 @@ def list_by_resource_group( more than 90. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoScaleVCoreListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.AutoScaleVCoreListResult] + :return: An iterator like instance of either AutoScaleVCoreListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.AutoScaleVCoreListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoScaleVCoreListResult"] @@ -324,35 +304,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - '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('AutoScaleVCoreListResult', pipeline_response) + deserialized = self._deserialize("AutoScaleVCoreListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -365,26 +341,30 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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.PowerBIDedicated/autoScaleVCores'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.AutoScaleVCoreListResult"]: """Lists all the auto scale v-cores for the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoScaleVCoreListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.AutoScaleVCoreListResult] + :return: An iterator like instance of either AutoScaleVCoreListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.AutoScaleVCoreListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoScaleVCoreListResult"] @@ -392,34 +372,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - } - 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('AutoScaleVCoreListResult', pipeline_response) + deserialized = self._deserialize("AutoScaleVCoreListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -432,12 +407,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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 ) diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_capacities_operations.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_capacities_operations.py index 413cd0f294574..f4227516f8344 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_capacities_operations.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_capacities_operations.py @@ -5,19 +5,24 @@ # 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._capacities_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_get_details_request, build_list_by_resource_group_request, build_list_request, build_list_skus_for_capacity_request, build_list_skus_request, build_resume_request_initial, build_suspend_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,11 +48,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_details( self, resource_group_name: str, dedicated_capacity_name: str, - **kwargs + **kwargs: Any ) -> "_models.DedicatedCapacity": """Gets details about the specified dedicated capacity. @@ -68,33 +74,23 @@ async def get_details( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_details.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_details_request( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self.get_details.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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DedicatedCapacity', pipeline_response) @@ -103,53 +99,44 @@ async def get_details( return cls(pipeline_response, deserialized, {}) return deserialized + get_details.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore + async def _create_initial( self, resource_group_name: str, dedicated_capacity_name: str, capacity_parameters: "_models.DedicatedCapacity", - **kwargs + **kwargs: Any ) -> "_models.DedicatedCapacity": cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacity"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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(capacity_parameters, 'DedicatedCapacity') - # 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_create_request_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.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(capacity_parameters, 'DedicatedCapacity') - 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(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('DedicatedCapacity', pipeline_response) @@ -161,14 +148,17 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, dedicated_capacity_name: str, capacity_parameters: "_models.DedicatedCapacity", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.DedicatedCapacity"]: """Provisions the specified Dedicated capacity based on the configuration specified in the request. @@ -184,15 +174,20 @@ async def begin_create( :type capacity_parameters: ~azure.mgmt.powerbidedicated.models.DedicatedCapacity :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DedicatedCapacity or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DedicatedCapacity or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacity"] lro_delay = kwargs.pop( 'polling_interval', @@ -204,27 +199,21 @@ async def begin_create( resource_group_name=resource_group_name, dedicated_capacity_name=dedicated_capacity_name, capacity_parameters=capacity_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DedicatedCapacity', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -236,58 +225,50 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore async def _delete_initial( self, resource_group_name: str, dedicated_capacity_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, dedicated_capacity_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified Dedicated capacity. @@ -300,15 +281,17 @@ async def begin_delete( :type dedicated_capacity_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -322,21 +305,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -348,6 +324,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore async def _update_initial( @@ -355,46 +332,35 @@ async def _update_initial( resource_group_name: str, dedicated_capacity_name: str, capacity_update_parameters: "_models.DedicatedCapacityUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.DedicatedCapacity": cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacity"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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(capacity_update_parameters, 'DedicatedCapacityUpdateParameters') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.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(capacity_update_parameters, 'DedicatedCapacityUpdateParameters') - 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, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('DedicatedCapacity', pipeline_response) @@ -406,14 +372,17 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, dedicated_capacity_name: str, capacity_update_parameters: "_models.DedicatedCapacityUpdateParameters", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.DedicatedCapacity"]: """Updates the current state of the specified Dedicated capacity. @@ -426,18 +395,24 @@ async def begin_update( :type dedicated_capacity_name: str :param capacity_update_parameters: Request object that contains the updated information for the capacity. - :type capacity_update_parameters: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityUpdateParameters + :type capacity_update_parameters: + ~azure.mgmt.powerbidedicated.models.DedicatedCapacityUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DedicatedCapacity or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DedicatedCapacity or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacity"] lro_delay = kwargs.pop( 'polling_interval', @@ -449,27 +424,21 @@ async def begin_update( resource_group_name=resource_group_name, dedicated_capacity_name=dedicated_capacity_name, capacity_update_parameters=capacity_update_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DedicatedCapacity', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -481,58 +450,50 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore async def _suspend_initial( self, resource_group_name: str, dedicated_capacity_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._suspend_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_suspend_request_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self._suspend_initial.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, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _suspend_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/suspend'} # type: ignore + + @distributed_trace_async async def begin_suspend( self, resource_group_name: str, dedicated_capacity_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Suspends operation of the specified dedicated capacity instance. @@ -545,15 +506,17 @@ async def begin_suspend( :type dedicated_capacity_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -567,21 +530,14 @@ async def begin_suspend( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -593,58 +549,50 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/suspend'} # type: ignore async def _resume_initial( self, resource_group_name: str, dedicated_capacity_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._resume_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_resume_request_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self._resume_initial.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, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/resume'} # type: ignore + + @distributed_trace_async async def begin_resume( self, resource_group_name: str, dedicated_capacity_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Resumes operation of the specified Dedicated capacity instance. @@ -657,15 +605,17 @@ async def begin_resume( :type dedicated_capacity_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -679,21 +629,14 @@ async def begin_resume( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -705,12 +648,14 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/resume'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DedicatedCapacities"]: """Gets all the Dedicated capacities for the given resource group. @@ -720,7 +665,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DedicatedCapacities or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.DedicatedCapacities] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.DedicatedCapacities] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacities"] @@ -728,35 +674,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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( + resource_group_name=resource_group_name, + 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('DedicatedCapacities', pipeline_response) + deserialized = self._deserialize("DedicatedCapacities", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -769,26 +711,29 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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.PowerBIDedicated/capacities'} # type: ignore + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DedicatedCapacities"]: """Lists all the Dedicated capacities for the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DedicatedCapacities or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.DedicatedCapacities] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.DedicatedCapacities] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacities"] @@ -796,34 +741,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('DedicatedCapacities', pipeline_response) + deserialized = self._deserialize("DedicatedCapacities", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -836,20 +776,22 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/capacities'} # type: ignore + @distributed_trace_async async def list_skus( self, - **kwargs + **kwargs: Any ) -> "_models.SkuEnumerationForNewResourceResult": """Lists eligible SKUs for PowerBI Dedicated resource provider. @@ -863,31 +805,21 @@ async def list_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.list_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_skus_request( + subscription_id=self._config.subscription_id, + template_url=self.list_skus.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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SkuEnumerationForNewResourceResult', pipeline_response) @@ -896,13 +828,16 @@ async def list_skus( return cls(pipeline_response, deserialized, {}) return deserialized + list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/skus'} # type: ignore + + @distributed_trace_async async def list_skus_for_capacity( self, resource_group_name: str, dedicated_capacity_name: str, - **kwargs + **kwargs: Any ) -> "_models.SkuEnumerationForExistingResourceResult": """Lists eligible SKUs for a PowerBI Dedicated resource. @@ -923,33 +858,23 @@ async def list_skus_for_capacity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.list_skus_for_capacity.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_skus_for_capacity_request( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self.list_skus_for_capacity.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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SkuEnumerationForExistingResourceResult', pipeline_response) @@ -958,20 +883,24 @@ async def list_skus_for_capacity( return cls(pipeline_response, deserialized, {}) return deserialized + list_skus_for_capacity.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/skus'} # type: ignore + + @distributed_trace_async async def check_name_availability( self, location: str, capacity_parameters: "_models.CheckCapacityNameAvailabilityParameters", - **kwargs + **kwargs: Any ) -> "_models.CheckCapacityNameAvailabilityResult": """Check the name availability in the target location. :param location: The region name which the operation will lookup into. :type location: str :param capacity_parameters: The name of the capacity. - :type capacity_parameters: ~azure.mgmt.powerbidedicated.models.CheckCapacityNameAvailabilityParameters + :type capacity_parameters: + ~azure.mgmt.powerbidedicated.models.CheckCapacityNameAvailabilityParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckCapacityNameAvailabilityResult, or the result of cls(response) :rtype: ~azure.mgmt.powerbidedicated.models.CheckCapacityNameAvailabilityResult @@ -982,37 +911,27 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'location': self._serialize.url("location", location, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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(capacity_parameters, 'CheckCapacityNameAvailabilityParameters') - # 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_check_name_availability_request( + location=location, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.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(capacity_parameters, 'CheckCapacityNameAvailabilityParameters') - 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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckCapacityNameAvailabilityResult', pipeline_response) @@ -1021,4 +940,6 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/locations/{location}/checkNameAvailability'} # type: ignore + diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_operations.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_operations.py index 969aa7adae394..d61c479caf802 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_operations.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/aio/operations/_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._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,17 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationListResult"]: """Lists all of the available PowerBIDedicated REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.powerbidedicated.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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.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_request( + template_url=self.list.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_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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 ) diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/__init__.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/__init__.py index c6c8542fa8ceb..a2ac92ba6627f 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/__init__.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/__init__.py @@ -6,58 +6,37 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AutoScaleVCore - from ._models_py3 import AutoScaleVCoreListResult - from ._models_py3 import AutoScaleVCoreMutableProperties - from ._models_py3 import AutoScaleVCoreProperties - from ._models_py3 import AutoScaleVCoreSku - from ._models_py3 import AutoScaleVCoreUpdateParameters - from ._models_py3 import CapacitySku - from ._models_py3 import CheckCapacityNameAvailabilityParameters - from ._models_py3 import CheckCapacityNameAvailabilityResult - from ._models_py3 import DedicatedCapacities - from ._models_py3 import DedicatedCapacity - from ._models_py3 import DedicatedCapacityAdministrators - from ._models_py3 import DedicatedCapacityMutableProperties - from ._models_py3 import DedicatedCapacityProperties - from ._models_py3 import DedicatedCapacityUpdateParameters - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import Resource - from ._models_py3 import SkuDetailsForExistingResource - from ._models_py3 import SkuEnumerationForExistingResourceResult - from ._models_py3 import SkuEnumerationForNewResourceResult - from ._models_py3 import SystemData -except (SyntaxError, ImportError): - from ._models import AutoScaleVCore # type: ignore - from ._models import AutoScaleVCoreListResult # type: ignore - from ._models import AutoScaleVCoreMutableProperties # type: ignore - from ._models import AutoScaleVCoreProperties # type: ignore - from ._models import AutoScaleVCoreSku # type: ignore - from ._models import AutoScaleVCoreUpdateParameters # type: ignore - from ._models import CapacitySku # type: ignore - from ._models import CheckCapacityNameAvailabilityParameters # type: ignore - from ._models import CheckCapacityNameAvailabilityResult # type: ignore - from ._models import DedicatedCapacities # type: ignore - from ._models import DedicatedCapacity # type: ignore - from ._models import DedicatedCapacityAdministrators # type: ignore - from ._models import DedicatedCapacityMutableProperties # type: ignore - from ._models import DedicatedCapacityProperties # type: ignore - from ._models import DedicatedCapacityUpdateParameters # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import Resource # type: ignore - from ._models import SkuDetailsForExistingResource # type: ignore - from ._models import SkuEnumerationForExistingResourceResult # type: ignore - from ._models import SkuEnumerationForNewResourceResult # type: ignore - from ._models import SystemData # type: ignore +from ._models_py3 import AutoScaleVCore +from ._models_py3 import AutoScaleVCoreListResult +from ._models_py3 import AutoScaleVCoreMutableProperties +from ._models_py3 import AutoScaleVCoreProperties +from ._models_py3 import AutoScaleVCoreSku +from ._models_py3 import AutoScaleVCoreUpdateParameters +from ._models_py3 import CapacitySku +from ._models_py3 import CheckCapacityNameAvailabilityParameters +from ._models_py3 import CheckCapacityNameAvailabilityResult +from ._models_py3 import DedicatedCapacities +from ._models_py3 import DedicatedCapacity +from ._models_py3 import DedicatedCapacityAdministrators +from ._models_py3 import DedicatedCapacityMutableProperties +from ._models_py3 import DedicatedCapacityProperties +from ._models_py3 import DedicatedCapacityUpdateParameters +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseError +from ._models_py3 import LogSpecification +from ._models_py3 import MetricSpecification +from ._models_py3 import MetricSpecificationDimensionsItem +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OperationProperties +from ._models_py3 import Resource +from ._models_py3 import ServiceSpecification +from ._models_py3 import SkuDetailsForExistingResource +from ._models_py3 import SkuEnumerationForExistingResourceResult +from ._models_py3 import SkuEnumerationForNewResourceResult +from ._models_py3 import SystemData + from ._power_bi_dedicated_enums import ( CapacityProvisioningState, @@ -87,10 +66,15 @@ 'DedicatedCapacityUpdateParameters', 'ErrorResponse', 'ErrorResponseError', + 'LogSpecification', + 'MetricSpecification', + 'MetricSpecificationDimensionsItem', 'Operation', 'OperationDisplay', 'OperationListResult', + 'OperationProperties', 'Resource', + 'ServiceSpecification', 'SkuDetailsForExistingResource', 'SkuEnumerationForExistingResourceResult', 'SkuEnumerationForNewResourceResult', diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_models.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_models.py deleted file mode 100644 index 7ab1e4a3b84c2..0000000000000 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_models.py +++ /dev/null @@ -1,798 +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): - """Represents an instance of an PowerBI Dedicated resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: An identifier that represents the PowerBI Dedicated resource. - :vartype id: str - :ivar name: The name of the PowerBI Dedicated resource. - :vartype name: str - :ivar type: The type of the PowerBI Dedicated resource. - :vartype type: str - :param location: Required. Location of the PowerBI Dedicated resource. - :type location: str - :param tags: A set of tags. Key-value pairs of additional resource provisioning properties. - :type tags: dict[str, str] - :param system_data: Metadata pertaining to creation and last modification of the resource. - :type system_data: ~azure.mgmt.powerbidedicated.models.SystemData - """ - - _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.system_data = kwargs.get('system_data', None) - - -class AutoScaleVCore(Resource): - """Represents an instance of an auto scale v-core resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: An identifier that represents the PowerBI Dedicated resource. - :vartype id: str - :ivar name: The name of the PowerBI Dedicated resource. - :vartype name: str - :ivar type: The type of the PowerBI Dedicated resource. - :vartype type: str - :param location: Required. Location of the PowerBI Dedicated resource. - :type location: str - :param tags: A set of tags. Key-value pairs of additional resource provisioning properties. - :type tags: dict[str, str] - :param system_data: Metadata pertaining to creation and last modification of the resource. - :type system_data: ~azure.mgmt.powerbidedicated.models.SystemData - :param sku: Required. The SKU of the auto scale v-core resource. - :type sku: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreSku - :param capacity_limit: The maximum capacity of an auto scale v-core resource. - :type capacity_limit: int - :param capacity_object_id: The object ID of the capacity resource associated with the auto - scale v-core resource. - :type capacity_object_id: str - :ivar provisioning_state: The current deployment state of an auto scale v-core resource. The - provisioningState is to indicate states for resource provisioning. Possible values include: - "Succeeded". - :vartype provisioning_state: str or ~azure.mgmt.powerbidedicated.models.VCoreProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'AutoScaleVCoreSku'}, - 'capacity_limit': {'key': 'properties.capacityLimit', 'type': 'int'}, - 'capacity_object_id': {'key': 'properties.capacityObjectId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoScaleVCore, self).__init__(**kwargs) - self.sku = kwargs['sku'] - self.capacity_limit = kwargs.get('capacity_limit', None) - self.capacity_object_id = kwargs.get('capacity_object_id', None) - self.provisioning_state = None - - -class AutoScaleVCoreListResult(msrest.serialization.Model): - """An array of auto scale v-core resources. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. An array of auto scale v-core resources. - :type value: list[~azure.mgmt.powerbidedicated.models.AutoScaleVCore] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AutoScaleVCore]'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoScaleVCoreListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class AutoScaleVCoreMutableProperties(msrest.serialization.Model): - """An object that represents a set of mutable auto scale v-core resource properties. - - :param capacity_limit: The maximum capacity of an auto scale v-core resource. - :type capacity_limit: int - """ - - _attribute_map = { - 'capacity_limit': {'key': 'capacityLimit', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoScaleVCoreMutableProperties, self).__init__(**kwargs) - self.capacity_limit = kwargs.get('capacity_limit', None) - - -class AutoScaleVCoreProperties(AutoScaleVCoreMutableProperties): - """Properties of an auto scale v-core resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param capacity_limit: The maximum capacity of an auto scale v-core resource. - :type capacity_limit: int - :param capacity_object_id: The object ID of the capacity resource associated with the auto - scale v-core resource. - :type capacity_object_id: str - :ivar provisioning_state: The current deployment state of an auto scale v-core resource. The - provisioningState is to indicate states for resource provisioning. Possible values include: - "Succeeded". - :vartype provisioning_state: str or ~azure.mgmt.powerbidedicated.models.VCoreProvisioningState - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'capacity_limit': {'key': 'capacityLimit', 'type': 'int'}, - 'capacity_object_id': {'key': 'capacityObjectId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoScaleVCoreProperties, self).__init__(**kwargs) - self.capacity_object_id = kwargs.get('capacity_object_id', None) - self.provisioning_state = None - - -class AutoScaleVCoreSku(msrest.serialization.Model): - """Represents the SKU name and Azure pricing tier for auto scale v-core resource. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the SKU level. - :type name: str - :param tier: The name of the Azure pricing tier to which the SKU applies. Possible values - include: "AutoScale". - :type tier: str or ~azure.mgmt.powerbidedicated.models.VCoreSkuTier - :param capacity: The capacity of an auto scale v-core resource. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoScaleVCoreSku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - self.capacity = kwargs.get('capacity', None) - - -class AutoScaleVCoreUpdateParameters(msrest.serialization.Model): - """Update request specification. - - :param sku: The SKU of the auto scale v-core resource. - :type sku: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreSku - :param tags: A set of tags. Key-value pairs of additional provisioning properties. - :type tags: dict[str, str] - :param capacity_limit: The maximum capacity of an auto scale v-core resource. - :type capacity_limit: int - """ - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'AutoScaleVCoreSku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'capacity_limit': {'key': 'properties.capacityLimit', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoScaleVCoreUpdateParameters, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.tags = kwargs.get('tags', None) - self.capacity_limit = kwargs.get('capacity_limit', None) - - -class CapacitySku(msrest.serialization.Model): - """Represents the SKU name and Azure pricing tier for PowerBI Dedicated capacity resource. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the SKU level. - :type name: str - :param tier: The name of the Azure pricing tier to which the SKU applies. Possible values - include: "PBIE_Azure", "Premium", "AutoPremiumHost". - :type tier: str or ~azure.mgmt.powerbidedicated.models.CapacitySkuTier - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CapacitySku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - - -class CheckCapacityNameAvailabilityParameters(msrest.serialization.Model): - """Details of capacity name request body. - - :param name: Name for checking availability. - :type name: str - :param type: The resource type of PowerBI dedicated. - :type type: str - """ - - _validation = { - 'name': {'max_length': 63, 'min_length': 3, 'pattern': r'^[a-z][a-z0-9]*$'}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckCapacityNameAvailabilityParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', "Microsoft.PowerBIDedicated/capacities") - - -class CheckCapacityNameAvailabilityResult(msrest.serialization.Model): - """The checking result of capacity name availability. - - :param name_available: Indicator of availability of the capacity name. - :type name_available: bool - :param reason: The reason of unavailability. - :type reason: str - :param message: The detailed message of the request unavailability. - :type message: str - """ - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckCapacityNameAvailabilityResult, self).__init__(**kwargs) - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - self.message = kwargs.get('message', None) - - -class DedicatedCapacities(msrest.serialization.Model): - """An array of Dedicated capacities resources. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. An array of Dedicated capacities resources. - :type value: list[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DedicatedCapacity]'}, - } - - def __init__( - self, - **kwargs - ): - super(DedicatedCapacities, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class DedicatedCapacity(Resource): - """Represents an instance of a Dedicated Capacity resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: An identifier that represents the PowerBI Dedicated resource. - :vartype id: str - :ivar name: The name of the PowerBI Dedicated resource. - :vartype name: str - :ivar type: The type of the PowerBI Dedicated resource. - :vartype type: str - :param location: Required. Location of the PowerBI Dedicated resource. - :type location: str - :param tags: A set of tags. Key-value pairs of additional resource provisioning properties. - :type tags: dict[str, str] - :param system_data: Metadata pertaining to creation and last modification of the resource. - :type system_data: ~azure.mgmt.powerbidedicated.models.SystemData - :param sku: Required. The SKU of the PowerBI Dedicated capacity resource. - :type sku: ~azure.mgmt.powerbidedicated.models.CapacitySku - :param administration: A collection of Dedicated capacity administrators. - :type administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators - :param mode: The capacity mode. Possible values include: "Gen1", "Gen2". - :type mode: str or ~azure.mgmt.powerbidedicated.models.Mode - :ivar state: The current state of PowerBI Dedicated resource. The state is to indicate more - states outside of resource provisioning. Possible values include: "Deleting", "Succeeded", - "Failed", "Paused", "Suspended", "Provisioning", "Updating", "Suspending", "Pausing", - "Resuming", "Preparing", "Scaling". - :vartype state: str or ~azure.mgmt.powerbidedicated.models.State - :ivar provisioning_state: The current deployment state of PowerBI Dedicated resource. The - provisioningState is to indicate states for resource provisioning. Possible values include: - "Deleting", "Succeeded", "Failed", "Paused", "Suspended", "Provisioning", "Updating", - "Suspending", "Pausing", "Resuming", "Preparing", "Scaling". - :vartype provisioning_state: str or - ~azure.mgmt.powerbidedicated.models.CapacityProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'CapacitySku'}, - 'administration': {'key': 'properties.administration', 'type': 'DedicatedCapacityAdministrators'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DedicatedCapacity, self).__init__(**kwargs) - self.sku = kwargs['sku'] - self.administration = kwargs.get('administration', None) - self.mode = kwargs.get('mode', None) - self.state = None - self.provisioning_state = None - - -class DedicatedCapacityAdministrators(msrest.serialization.Model): - """An array of administrator user identities. - - :param members: An array of administrator user identities. - :type members: list[str] - """ - - _attribute_map = { - 'members': {'key': 'members', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DedicatedCapacityAdministrators, self).__init__(**kwargs) - self.members = kwargs.get('members', None) - - -class DedicatedCapacityMutableProperties(msrest.serialization.Model): - """An object that represents a set of mutable Dedicated capacity resource properties. - - :param administration: A collection of Dedicated capacity administrators. - :type administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators - :param mode: The capacity mode. Possible values include: "Gen1", "Gen2". - :type mode: str or ~azure.mgmt.powerbidedicated.models.Mode - """ - - _attribute_map = { - 'administration': {'key': 'administration', 'type': 'DedicatedCapacityAdministrators'}, - 'mode': {'key': 'mode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DedicatedCapacityMutableProperties, self).__init__(**kwargs) - self.administration = kwargs.get('administration', None) - self.mode = kwargs.get('mode', None) - - -class DedicatedCapacityProperties(DedicatedCapacityMutableProperties): - """Properties of Dedicated Capacity resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param administration: A collection of Dedicated capacity administrators. - :type administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators - :param mode: The capacity mode. Possible values include: "Gen1", "Gen2". - :type mode: str or ~azure.mgmt.powerbidedicated.models.Mode - :ivar state: The current state of PowerBI Dedicated resource. The state is to indicate more - states outside of resource provisioning. Possible values include: "Deleting", "Succeeded", - "Failed", "Paused", "Suspended", "Provisioning", "Updating", "Suspending", "Pausing", - "Resuming", "Preparing", "Scaling". - :vartype state: str or ~azure.mgmt.powerbidedicated.models.State - :ivar provisioning_state: The current deployment state of PowerBI Dedicated resource. The - provisioningState is to indicate states for resource provisioning. Possible values include: - "Deleting", "Succeeded", "Failed", "Paused", "Suspended", "Provisioning", "Updating", - "Suspending", "Pausing", "Resuming", "Preparing", "Scaling". - :vartype provisioning_state: str or - ~azure.mgmt.powerbidedicated.models.CapacityProvisioningState - """ - - _validation = { - 'state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'administration': {'key': 'administration', 'type': 'DedicatedCapacityAdministrators'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DedicatedCapacityProperties, self).__init__(**kwargs) - self.state = None - self.provisioning_state = None - - -class DedicatedCapacityUpdateParameters(msrest.serialization.Model): - """Provision request specification. - - :param sku: The SKU of the Dedicated capacity resource. - :type sku: ~azure.mgmt.powerbidedicated.models.CapacitySku - :param tags: A set of tags. Key-value pairs of additional provisioning properties. - :type tags: dict[str, str] - :param administration: A collection of Dedicated capacity administrators. - :type administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators - :param mode: The capacity mode. Possible values include: "Gen1", "Gen2". - :type mode: str or ~azure.mgmt.powerbidedicated.models.Mode - """ - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'CapacitySku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'administration': {'key': 'properties.administration', 'type': 'DedicatedCapacityAdministrators'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DedicatedCapacityUpdateParameters, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.tags = kwargs.get('tags', None) - self.administration = kwargs.get('administration', None) - self.mode = kwargs.get('mode', None) - - -class ErrorResponse(msrest.serialization.Model): - """Describes the format of Error response. - - :param error: The error object. - :type error: ~azure.mgmt.powerbidedicated.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class Operation(msrest.serialization.Model): - """Capacities REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.powerbidedicated.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft.PowerBIDedicated. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: capacity, etc. - :vartype resource: str - :ivar operation: Operation type: create, update, delete, etc. - :vartype operation: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationListResult(msrest.serialization.Model): - """Result listing capacities. It contains a list of operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of capacities supported by the Microsoft.PowerBIDedicated resource provider. - :vartype value: list[~azure.mgmt.powerbidedicated.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SkuDetailsForExistingResource(msrest.serialization.Model): - """An object that represents SKU details for existing resources. - - :param sku: The SKU in SKU details for existing resources. - :type sku: ~azure.mgmt.powerbidedicated.models.CapacitySku - """ - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'CapacitySku'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuDetailsForExistingResource, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - - -class SkuEnumerationForExistingResourceResult(msrest.serialization.Model): - """An object that represents enumerating SKUs for existing resources. - - :param value: The collection of available SKUs for existing resources. - :type value: list[~azure.mgmt.powerbidedicated.models.SkuDetailsForExistingResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuDetailsForExistingResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuEnumerationForExistingResourceResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SkuEnumerationForNewResourceResult(msrest.serialization.Model): - """An object that represents enumerating SKUs for new resources. - - :param value: The collection of available SKUs for new resources. - :type value: list[~azure.mgmt.powerbidedicated.models.CapacitySku] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CapacitySku]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuEnumerationForNewResourceResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: An identifier for 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.powerbidedicated.models.IdentityType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: An identifier for 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.powerbidedicated.models.IdentityType - :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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_models_py3.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_models_py3.py index 72ea08ea8a8ed..6bfa7fd3538d9 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_models_py3.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_models_py3.py @@ -28,12 +28,12 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the PowerBI Dedicated resource. :vartype type: str - :param location: Required. Location of the PowerBI Dedicated resource. - :type location: str - :param tags: A set of tags. Key-value pairs of additional resource provisioning properties. - :type tags: dict[str, str] - :param system_data: Metadata pertaining to creation and last modification of the resource. - :type system_data: ~azure.mgmt.powerbidedicated.models.SystemData + :ivar location: Required. Location of the PowerBI Dedicated resource. + :vartype location: str + :ivar tags: A set of tags. Key-value pairs of additional resource provisioning properties. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.powerbidedicated.models.SystemData """ _validation = { @@ -60,6 +60,14 @@ def __init__( system_data: Optional["SystemData"] = None, **kwargs ): + """ + :keyword location: Required. Location of the PowerBI Dedicated resource. + :paramtype location: str + :keyword tags: A set of tags. Key-value pairs of additional resource provisioning properties. + :paramtype tags: dict[str, str] + :keyword system_data: Metadata pertaining to creation and last modification of the resource. + :paramtype system_data: ~azure.mgmt.powerbidedicated.models.SystemData + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -82,19 +90,19 @@ class AutoScaleVCore(Resource): :vartype name: str :ivar type: The type of the PowerBI Dedicated resource. :vartype type: str - :param location: Required. Location of the PowerBI Dedicated resource. - :type location: str - :param tags: A set of tags. Key-value pairs of additional resource provisioning properties. - :type tags: dict[str, str] - :param system_data: Metadata pertaining to creation and last modification of the resource. - :type system_data: ~azure.mgmt.powerbidedicated.models.SystemData - :param sku: Required. The SKU of the auto scale v-core resource. - :type sku: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreSku - :param capacity_limit: The maximum capacity of an auto scale v-core resource. - :type capacity_limit: int - :param capacity_object_id: The object ID of the capacity resource associated with the auto - scale v-core resource. - :type capacity_object_id: str + :ivar location: Required. Location of the PowerBI Dedicated resource. + :vartype location: str + :ivar tags: A set of tags. Key-value pairs of additional resource provisioning properties. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.powerbidedicated.models.SystemData + :ivar sku: Required. The SKU of the auto scale v-core resource. + :vartype sku: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreSku + :ivar capacity_limit: The maximum capacity of an auto scale v-core resource. + :vartype capacity_limit: int + :ivar capacity_object_id: The object ID of the capacity resource associated with the auto scale + v-core resource. + :vartype capacity_object_id: str :ivar provisioning_state: The current deployment state of an auto scale v-core resource. The provisioningState is to indicate states for resource provisioning. Possible values include: "Succeeded". @@ -134,6 +142,21 @@ def __init__( capacity_object_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Location of the PowerBI Dedicated resource. + :paramtype location: str + :keyword tags: A set of tags. Key-value pairs of additional resource provisioning properties. + :paramtype tags: dict[str, str] + :keyword system_data: Metadata pertaining to creation and last modification of the resource. + :paramtype system_data: ~azure.mgmt.powerbidedicated.models.SystemData + :keyword sku: Required. The SKU of the auto scale v-core resource. + :paramtype sku: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreSku + :keyword capacity_limit: The maximum capacity of an auto scale v-core resource. + :paramtype capacity_limit: int + :keyword capacity_object_id: The object ID of the capacity resource associated with the auto + scale v-core resource. + :paramtype capacity_object_id: str + """ super(AutoScaleVCore, self).__init__(location=location, tags=tags, system_data=system_data, **kwargs) self.sku = sku self.capacity_limit = capacity_limit @@ -146,8 +169,8 @@ class AutoScaleVCoreListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. An array of auto scale v-core resources. - :type value: list[~azure.mgmt.powerbidedicated.models.AutoScaleVCore] + :ivar value: Required. An array of auto scale v-core resources. + :vartype value: list[~azure.mgmt.powerbidedicated.models.AutoScaleVCore] """ _validation = { @@ -164,6 +187,10 @@ def __init__( value: List["AutoScaleVCore"], **kwargs ): + """ + :keyword value: Required. An array of auto scale v-core resources. + :paramtype value: list[~azure.mgmt.powerbidedicated.models.AutoScaleVCore] + """ super(AutoScaleVCoreListResult, self).__init__(**kwargs) self.value = value @@ -171,8 +198,8 @@ def __init__( class AutoScaleVCoreMutableProperties(msrest.serialization.Model): """An object that represents a set of mutable auto scale v-core resource properties. - :param capacity_limit: The maximum capacity of an auto scale v-core resource. - :type capacity_limit: int + :ivar capacity_limit: The maximum capacity of an auto scale v-core resource. + :vartype capacity_limit: int """ _attribute_map = { @@ -185,6 +212,10 @@ def __init__( capacity_limit: Optional[int] = None, **kwargs ): + """ + :keyword capacity_limit: The maximum capacity of an auto scale v-core resource. + :paramtype capacity_limit: int + """ super(AutoScaleVCoreMutableProperties, self).__init__(**kwargs) self.capacity_limit = capacity_limit @@ -194,11 +225,11 @@ class AutoScaleVCoreProperties(AutoScaleVCoreMutableProperties): Variables are only populated by the server, and will be ignored when sending a request. - :param capacity_limit: The maximum capacity of an auto scale v-core resource. - :type capacity_limit: int - :param capacity_object_id: The object ID of the capacity resource associated with the auto - scale v-core resource. - :type capacity_object_id: str + :ivar capacity_limit: The maximum capacity of an auto scale v-core resource. + :vartype capacity_limit: int + :ivar capacity_object_id: The object ID of the capacity resource associated with the auto scale + v-core resource. + :vartype capacity_object_id: str :ivar provisioning_state: The current deployment state of an auto scale v-core resource. The provisioningState is to indicate states for resource provisioning. Possible values include: "Succeeded". @@ -222,6 +253,13 @@ def __init__( capacity_object_id: Optional[str] = None, **kwargs ): + """ + :keyword capacity_limit: The maximum capacity of an auto scale v-core resource. + :paramtype capacity_limit: int + :keyword capacity_object_id: The object ID of the capacity resource associated with the auto + scale v-core resource. + :paramtype capacity_object_id: str + """ super(AutoScaleVCoreProperties, self).__init__(capacity_limit=capacity_limit, **kwargs) self.capacity_object_id = capacity_object_id self.provisioning_state = None @@ -232,13 +270,13 @@ class AutoScaleVCoreSku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the SKU level. - :type name: str - :param tier: The name of the Azure pricing tier to which the SKU applies. Possible values + :ivar name: Required. Name of the SKU level. + :vartype name: str + :ivar tier: The name of the Azure pricing tier to which the SKU applies. Possible values include: "AutoScale". - :type tier: str or ~azure.mgmt.powerbidedicated.models.VCoreSkuTier - :param capacity: The capacity of an auto scale v-core resource. - :type capacity: int + :vartype tier: str or ~azure.mgmt.powerbidedicated.models.VCoreSkuTier + :ivar capacity: The capacity of an auto scale v-core resource. + :vartype capacity: int """ _validation = { @@ -259,6 +297,15 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. Name of the SKU level. + :paramtype name: str + :keyword tier: The name of the Azure pricing tier to which the SKU applies. Possible values + include: "AutoScale". + :paramtype tier: str or ~azure.mgmt.powerbidedicated.models.VCoreSkuTier + :keyword capacity: The capacity of an auto scale v-core resource. + :paramtype capacity: int + """ super(AutoScaleVCoreSku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -268,12 +315,12 @@ def __init__( class AutoScaleVCoreUpdateParameters(msrest.serialization.Model): """Update request specification. - :param sku: The SKU of the auto scale v-core resource. - :type sku: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreSku - :param tags: A set of tags. Key-value pairs of additional provisioning properties. - :type tags: dict[str, str] - :param capacity_limit: The maximum capacity of an auto scale v-core resource. - :type capacity_limit: int + :ivar sku: The SKU of the auto scale v-core resource. + :vartype sku: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreSku + :ivar tags: A set of tags. Key-value pairs of additional provisioning properties. + :vartype tags: dict[str, str] + :ivar capacity_limit: The maximum capacity of an auto scale v-core resource. + :vartype capacity_limit: int """ _attribute_map = { @@ -290,6 +337,14 @@ def __init__( capacity_limit: Optional[int] = None, **kwargs ): + """ + :keyword sku: The SKU of the auto scale v-core resource. + :paramtype sku: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreSku + :keyword tags: A set of tags. Key-value pairs of additional provisioning properties. + :paramtype tags: dict[str, str] + :keyword capacity_limit: The maximum capacity of an auto scale v-core resource. + :paramtype capacity_limit: int + """ super(AutoScaleVCoreUpdateParameters, self).__init__(**kwargs) self.sku = sku self.tags = tags @@ -301,11 +356,13 @@ class CapacitySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the SKU level. - :type name: str - :param tier: The name of the Azure pricing tier to which the SKU applies. Possible values + :ivar name: Required. Name of the SKU level. + :vartype name: str + :ivar tier: The name of the Azure pricing tier to which the SKU applies. Possible values include: "PBIE_Azure", "Premium", "AutoPremiumHost". - :type tier: str or ~azure.mgmt.powerbidedicated.models.CapacitySkuTier + :vartype tier: str or ~azure.mgmt.powerbidedicated.models.CapacitySkuTier + :ivar capacity: The capacity of the SKU. + :vartype capacity: int """ _validation = { @@ -315,6 +372,7 @@ class CapacitySku(msrest.serialization.Model): _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'tier': {'key': 'tier', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, } def __init__( @@ -322,20 +380,31 @@ def __init__( *, name: str, tier: Optional[Union[str, "CapacitySkuTier"]] = None, + capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. Name of the SKU level. + :paramtype name: str + :keyword tier: The name of the Azure pricing tier to which the SKU applies. Possible values + include: "PBIE_Azure", "Premium", "AutoPremiumHost". + :paramtype tier: str or ~azure.mgmt.powerbidedicated.models.CapacitySkuTier + :keyword capacity: The capacity of the SKU. + :paramtype capacity: int + """ super(CapacitySku, self).__init__(**kwargs) self.name = name self.tier = tier + self.capacity = capacity class CheckCapacityNameAvailabilityParameters(msrest.serialization.Model): """Details of capacity name request body. - :param name: Name for checking availability. - :type name: str - :param type: The resource type of PowerBI dedicated. - :type type: str + :ivar name: Name for checking availability. + :vartype name: str + :ivar type: The resource type of PowerBI dedicated. + :vartype type: str """ _validation = { @@ -354,6 +423,12 @@ def __init__( type: Optional[str] = "Microsoft.PowerBIDedicated/capacities", **kwargs ): + """ + :keyword name: Name for checking availability. + :paramtype name: str + :keyword type: The resource type of PowerBI dedicated. + :paramtype type: str + """ super(CheckCapacityNameAvailabilityParameters, self).__init__(**kwargs) self.name = name self.type = type @@ -362,12 +437,12 @@ def __init__( class CheckCapacityNameAvailabilityResult(msrest.serialization.Model): """The checking result of capacity name availability. - :param name_available: Indicator of availability of the capacity name. - :type name_available: bool - :param reason: The reason of unavailability. - :type reason: str - :param message: The detailed message of the request unavailability. - :type message: str + :ivar name_available: Indicator of availability of the capacity name. + :vartype name_available: bool + :ivar reason: The reason of unavailability. + :vartype reason: str + :ivar message: The detailed message of the request unavailability. + :vartype message: str """ _attribute_map = { @@ -384,6 +459,14 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword name_available: Indicator of availability of the capacity name. + :paramtype name_available: bool + :keyword reason: The reason of unavailability. + :paramtype reason: str + :keyword message: The detailed message of the request unavailability. + :paramtype message: str + """ super(CheckCapacityNameAvailabilityResult, self).__init__(**kwargs) self.name_available = name_available self.reason = reason @@ -395,8 +478,8 @@ class DedicatedCapacities(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. An array of Dedicated capacities resources. - :type value: list[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] + :ivar value: Required. An array of Dedicated capacities resources. + :vartype value: list[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] """ _validation = { @@ -413,6 +496,10 @@ def __init__( value: List["DedicatedCapacity"], **kwargs ): + """ + :keyword value: Required. An array of Dedicated capacities resources. + :paramtype value: list[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] + """ super(DedicatedCapacities, self).__init__(**kwargs) self.value = value @@ -430,18 +517,25 @@ class DedicatedCapacity(Resource): :vartype name: str :ivar type: The type of the PowerBI Dedicated resource. :vartype type: str - :param location: Required. Location of the PowerBI Dedicated resource. - :type location: str - :param tags: A set of tags. Key-value pairs of additional resource provisioning properties. - :type tags: dict[str, str] - :param system_data: Metadata pertaining to creation and last modification of the resource. - :type system_data: ~azure.mgmt.powerbidedicated.models.SystemData - :param sku: Required. The SKU of the PowerBI Dedicated capacity resource. - :type sku: ~azure.mgmt.powerbidedicated.models.CapacitySku - :param administration: A collection of Dedicated capacity administrators. - :type administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators - :param mode: The capacity mode. Possible values include: "Gen1", "Gen2". - :type mode: str or ~azure.mgmt.powerbidedicated.models.Mode + :ivar location: Required. Location of the PowerBI Dedicated resource. + :vartype location: str + :ivar tags: A set of tags. Key-value pairs of additional resource provisioning properties. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.powerbidedicated.models.SystemData + :ivar sku: Required. The SKU of the PowerBI Dedicated capacity resource. + :vartype sku: ~azure.mgmt.powerbidedicated.models.CapacitySku + :ivar administration: A collection of Dedicated capacity administrators. + :vartype administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators + :ivar mode: Specifies the generation of the Power BI Embedded capacity. If no value is + specified, the default value 'Gen2' is used. `Learn More + `_. + Possible values include: "Gen1", "Gen2". + :vartype mode: str or ~azure.mgmt.powerbidedicated.models.Mode + :ivar tenant_id: Tenant ID for the capacity. Used for creating Pro Plus capacity. + :vartype tenant_id: str + :ivar friendly_name: Capacity name. + :vartype friendly_name: str :ivar state: The current state of PowerBI Dedicated resource. The state is to indicate more states outside of resource provisioning. Possible values include: "Deleting", "Succeeded", "Failed", "Paused", "Suspended", "Provisioning", "Updating", "Suspending", "Pausing", @@ -461,6 +555,8 @@ class DedicatedCapacity(Resource): 'type': {'readonly': True}, 'location': {'required': True}, 'sku': {'required': True}, + 'tenant_id': {'readonly': True}, + 'friendly_name': {'readonly': True}, 'state': {'readonly': True}, 'provisioning_state': {'readonly': True}, } @@ -475,6 +571,8 @@ class DedicatedCapacity(Resource): 'sku': {'key': 'sku', 'type': 'CapacitySku'}, 'administration': {'key': 'properties.administration', 'type': 'DedicatedCapacityAdministrators'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, 'state': {'key': 'properties.state', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } @@ -490,10 +588,29 @@ def __init__( mode: Optional[Union[str, "Mode"]] = None, **kwargs ): + """ + :keyword location: Required. Location of the PowerBI Dedicated resource. + :paramtype location: str + :keyword tags: A set of tags. Key-value pairs of additional resource provisioning properties. + :paramtype tags: dict[str, str] + :keyword system_data: Metadata pertaining to creation and last modification of the resource. + :paramtype system_data: ~azure.mgmt.powerbidedicated.models.SystemData + :keyword sku: Required. The SKU of the PowerBI Dedicated capacity resource. + :paramtype sku: ~azure.mgmt.powerbidedicated.models.CapacitySku + :keyword administration: A collection of Dedicated capacity administrators. + :paramtype administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators + :keyword mode: Specifies the generation of the Power BI Embedded capacity. If no value is + specified, the default value 'Gen2' is used. `Learn More + `_. + Possible values include: "Gen1", "Gen2". + :paramtype mode: str or ~azure.mgmt.powerbidedicated.models.Mode + """ super(DedicatedCapacity, self).__init__(location=location, tags=tags, system_data=system_data, **kwargs) self.sku = sku self.administration = administration self.mode = mode + self.tenant_id = None + self.friendly_name = None self.state = None self.provisioning_state = None @@ -501,8 +618,8 @@ def __init__( class DedicatedCapacityAdministrators(msrest.serialization.Model): """An array of administrator user identities. - :param members: An array of administrator user identities. - :type members: list[str] + :ivar members: An array of administrator user identities. + :vartype members: list[str] """ _attribute_map = { @@ -515,6 +632,10 @@ def __init__( members: Optional[List[str]] = None, **kwargs ): + """ + :keyword members: An array of administrator user identities. + :paramtype members: list[str] + """ super(DedicatedCapacityAdministrators, self).__init__(**kwargs) self.members = members @@ -522,15 +643,31 @@ def __init__( class DedicatedCapacityMutableProperties(msrest.serialization.Model): """An object that represents a set of mutable Dedicated capacity resource properties. - :param administration: A collection of Dedicated capacity administrators. - :type administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators - :param mode: The capacity mode. Possible values include: "Gen1", "Gen2". - :type mode: str or ~azure.mgmt.powerbidedicated.models.Mode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar administration: A collection of Dedicated capacity administrators. + :vartype administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators + :ivar mode: Specifies the generation of the Power BI Embedded capacity. If no value is + specified, the default value 'Gen2' is used. `Learn More + `_. + Possible values include: "Gen1", "Gen2". + :vartype mode: str or ~azure.mgmt.powerbidedicated.models.Mode + :ivar tenant_id: Tenant ID for the capacity. Used for creating Pro Plus capacity. + :vartype tenant_id: str + :ivar friendly_name: Capacity name. + :vartype friendly_name: str """ + _validation = { + 'tenant_id': {'readonly': True}, + 'friendly_name': {'readonly': True}, + } + _attribute_map = { 'administration': {'key': 'administration', 'type': 'DedicatedCapacityAdministrators'}, 'mode': {'key': 'mode', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, } def __init__( @@ -540,9 +677,20 @@ def __init__( mode: Optional[Union[str, "Mode"]] = None, **kwargs ): + """ + :keyword administration: A collection of Dedicated capacity administrators. + :paramtype administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators + :keyword mode: Specifies the generation of the Power BI Embedded capacity. If no value is + specified, the default value 'Gen2' is used. `Learn More + `_. + Possible values include: "Gen1", "Gen2". + :paramtype mode: str or ~azure.mgmt.powerbidedicated.models.Mode + """ super(DedicatedCapacityMutableProperties, self).__init__(**kwargs) self.administration = administration self.mode = mode + self.tenant_id = None + self.friendly_name = None class DedicatedCapacityProperties(DedicatedCapacityMutableProperties): @@ -550,10 +698,17 @@ class DedicatedCapacityProperties(DedicatedCapacityMutableProperties): Variables are only populated by the server, and will be ignored when sending a request. - :param administration: A collection of Dedicated capacity administrators. - :type administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators - :param mode: The capacity mode. Possible values include: "Gen1", "Gen2". - :type mode: str or ~azure.mgmt.powerbidedicated.models.Mode + :ivar administration: A collection of Dedicated capacity administrators. + :vartype administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators + :ivar mode: Specifies the generation of the Power BI Embedded capacity. If no value is + specified, the default value 'Gen2' is used. `Learn More + `_. + Possible values include: "Gen1", "Gen2". + :vartype mode: str or ~azure.mgmt.powerbidedicated.models.Mode + :ivar tenant_id: Tenant ID for the capacity. Used for creating Pro Plus capacity. + :vartype tenant_id: str + :ivar friendly_name: Capacity name. + :vartype friendly_name: str :ivar state: The current state of PowerBI Dedicated resource. The state is to indicate more states outside of resource provisioning. Possible values include: "Deleting", "Succeeded", "Failed", "Paused", "Suspended", "Provisioning", "Updating", "Suspending", "Pausing", @@ -568,6 +723,8 @@ class DedicatedCapacityProperties(DedicatedCapacityMutableProperties): """ _validation = { + 'tenant_id': {'readonly': True}, + 'friendly_name': {'readonly': True}, 'state': {'readonly': True}, 'provisioning_state': {'readonly': True}, } @@ -575,6 +732,8 @@ class DedicatedCapacityProperties(DedicatedCapacityMutableProperties): _attribute_map = { 'administration': {'key': 'administration', 'type': 'DedicatedCapacityAdministrators'}, 'mode': {'key': 'mode', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, 'state': {'key': 'state', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } @@ -586,6 +745,15 @@ def __init__( mode: Optional[Union[str, "Mode"]] = None, **kwargs ): + """ + :keyword administration: A collection of Dedicated capacity administrators. + :paramtype administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators + :keyword mode: Specifies the generation of the Power BI Embedded capacity. If no value is + specified, the default value 'Gen2' is used. `Learn More + `_. + Possible values include: "Gen1", "Gen2". + :paramtype mode: str or ~azure.mgmt.powerbidedicated.models.Mode + """ super(DedicatedCapacityProperties, self).__init__(administration=administration, mode=mode, **kwargs) self.state = None self.provisioning_state = None @@ -594,21 +762,37 @@ def __init__( class DedicatedCapacityUpdateParameters(msrest.serialization.Model): """Provision request specification. - :param sku: The SKU of the Dedicated capacity resource. - :type sku: ~azure.mgmt.powerbidedicated.models.CapacitySku - :param tags: A set of tags. Key-value pairs of additional provisioning properties. - :type tags: dict[str, str] - :param administration: A collection of Dedicated capacity administrators. - :type administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators - :param mode: The capacity mode. Possible values include: "Gen1", "Gen2". - :type mode: str or ~azure.mgmt.powerbidedicated.models.Mode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar sku: The SKU of the Dedicated capacity resource. + :vartype sku: ~azure.mgmt.powerbidedicated.models.CapacitySku + :ivar tags: A set of tags. Key-value pairs of additional provisioning properties. + :vartype tags: dict[str, str] + :ivar administration: A collection of Dedicated capacity administrators. + :vartype administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators + :ivar mode: Specifies the generation of the Power BI Embedded capacity. If no value is + specified, the default value 'Gen2' is used. `Learn More + `_. + Possible values include: "Gen1", "Gen2". + :vartype mode: str or ~azure.mgmt.powerbidedicated.models.Mode + :ivar tenant_id: Tenant ID for the capacity. Used for creating Pro Plus capacity. + :vartype tenant_id: str + :ivar friendly_name: Capacity name. + :vartype friendly_name: str """ + _validation = { + 'tenant_id': {'readonly': True}, + 'friendly_name': {'readonly': True}, + } + _attribute_map = { 'sku': {'key': 'sku', 'type': 'CapacitySku'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'administration': {'key': 'properties.administration', 'type': 'DedicatedCapacityAdministrators'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, } def __init__( @@ -620,18 +804,33 @@ def __init__( mode: Optional[Union[str, "Mode"]] = None, **kwargs ): + """ + :keyword sku: The SKU of the Dedicated capacity resource. + :paramtype sku: ~azure.mgmt.powerbidedicated.models.CapacitySku + :keyword tags: A set of tags. Key-value pairs of additional provisioning properties. + :paramtype tags: dict[str, str] + :keyword administration: A collection of Dedicated capacity administrators. + :paramtype administration: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityAdministrators + :keyword mode: Specifies the generation of the Power BI Embedded capacity. If no value is + specified, the default value 'Gen2' is used. `Learn More + `_. + Possible values include: "Gen1", "Gen2". + :paramtype mode: str or ~azure.mgmt.powerbidedicated.models.Mode + """ super(DedicatedCapacityUpdateParameters, self).__init__(**kwargs) self.sku = sku self.tags = tags self.administration = administration self.mode = mode + self.tenant_id = None + self.friendly_name = None class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param error: The error object. - :type error: ~azure.mgmt.powerbidedicated.models.ErrorResponseError + :ivar error: The error object. + :vartype error: ~azure.mgmt.powerbidedicated.models.ErrorResponseError """ _attribute_map = { @@ -644,6 +843,10 @@ def __init__( error: Optional["ErrorResponseError"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.powerbidedicated.models.ErrorResponseError + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -651,10 +854,10 @@ def __init__( class ErrorResponseError(msrest.serialization.Model): """The error object. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -669,11 +872,158 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponseError, self).__init__(**kwargs) self.code = code self.message = message +class LogSpecification(msrest.serialization.Model): + """Log specification for exposing diagnostic logs to shoebox. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Localizable name of the log. + :vartype display_name: str + :ivar blob_duration: Blob duration for the log. + :vartype blob_duration: str + """ + + _validation = { + 'name': {'readonly': True}, + 'blob_duration': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword display_name: Localizable name of the log. + :paramtype display_name: str + """ + super(LogSpecification, self).__init__(**kwargs) + self.name = None + self.display_name = display_name + self.blob_duration = None + + +class MetricSpecification(msrest.serialization.Model): + """Metric specification for exposing performance metrics to shoebox. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Metric name. + :vartype name: str + :ivar display_name: Localizable metric name. + :vartype display_name: str + :ivar display_description: Localizable description of metric. + :vartype display_description: str + :ivar unit: Unit for the metric. + :vartype unit: str + :ivar aggregation_type: Aggregation type for the metric. + :vartype aggregation_type: str + :ivar metric_filter_pattern: Pattern used to filter the metric. + :vartype metric_filter_pattern: str + :ivar dimensions: For describing multi dimensional metrics. + :vartype dimensions: + list[~azure.mgmt.powerbidedicated.models.MetricSpecificationDimensionsItem] + """ + + _validation = { + 'name': {'readonly': True}, + 'unit': {'readonly': True}, + 'aggregation_type': {'readonly': True}, + 'metric_filter_pattern': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'display_description': {'key': 'displayDescription', 'type': 'str'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, + 'metric_filter_pattern': {'key': 'metricFilterPattern', 'type': 'str'}, + 'dimensions': {'key': 'dimensions', 'type': '[MetricSpecificationDimensionsItem]'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + dimensions: Optional[List["MetricSpecificationDimensionsItem"]] = None, + **kwargs + ): + """ + :keyword display_name: Localizable metric name. + :paramtype display_name: str + :keyword display_description: Localizable description of metric. + :paramtype display_description: str + :keyword dimensions: For describing multi dimensional metrics. + :paramtype dimensions: + list[~azure.mgmt.powerbidedicated.models.MetricSpecificationDimensionsItem] + """ + super(MetricSpecification, self).__init__(**kwargs) + self.name = None + self.display_name = display_name + self.display_description = display_description + self.unit = None + self.aggregation_type = None + self.metric_filter_pattern = None + self.dimensions = dimensions + + +class MetricSpecificationDimensionsItem(msrest.serialization.Model): + """MetricSpecificationDimensionsItem. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Dimension of the metric. + :vartype name: str + :ivar display_name: Localizable dimension of the metric. + :vartype display_name: str + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword display_name: Localizable dimension of the metric. + :paramtype display_name: str + """ + super(MetricSpecificationDimensionsItem, self).__init__(**kwargs) + self.name = None + self.display_name = display_name + + class Operation(msrest.serialization.Model): """Capacities REST API operation. @@ -681,28 +1031,44 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.powerbidedicated.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.powerbidedicated.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Additional properties to expose performance metrics to shoebox. + :vartype properties: ~azure.mgmt.powerbidedicated.models.OperationProperties """ _validation = { 'name': {'readonly': True}, + 'origin': {'readonly': True}, } _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'OperationProperties'}, } def __init__( self, *, display: Optional["OperationDisplay"] = None, + properties: Optional["OperationProperties"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.powerbidedicated.models.OperationDisplay + :keyword properties: Additional properties to expose performance metrics to shoebox. + :paramtype properties: ~azure.mgmt.powerbidedicated.models.OperationProperties + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display + self.origin = None + self.properties = properties class OperationDisplay(msrest.serialization.Model): @@ -716,6 +1082,8 @@ class OperationDisplay(msrest.serialization.Model): :vartype resource: str :ivar operation: Operation type: create, update, delete, etc. :vartype operation: str + :ivar description: Localized description of the operation. + :vartype description: str """ _validation = { @@ -728,16 +1096,24 @@ class OperationDisplay(msrest.serialization.Model): 'provider': {'key': 'provider', 'type': 'str'}, 'resource': {'key': 'resource', 'type': 'str'}, 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, } def __init__( self, + *, + description: Optional[str] = None, **kwargs ): + """ + :keyword description: Localized description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None self.operation = None + self.description = description class OperationListResult(msrest.serialization.Model): @@ -765,37 +1141,109 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None +class OperationProperties(msrest.serialization.Model): + """Additional properties to expose performance metrics to shoebox. + + :ivar service_specification: Service specification for exposing performance metrics to shoebox. + :vartype service_specification: ~azure.mgmt.powerbidedicated.models.ServiceSpecification + """ + + _attribute_map = { + 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + } + + def __init__( + self, + *, + service_specification: Optional["ServiceSpecification"] = None, + **kwargs + ): + """ + :keyword service_specification: Service specification for exposing performance metrics to + shoebox. + :paramtype service_specification: ~azure.mgmt.powerbidedicated.models.ServiceSpecification + """ + super(OperationProperties, self).__init__(**kwargs) + self.service_specification = service_specification + + +class ServiceSpecification(msrest.serialization.Model): + """Service specification for exposing performance metrics to shoebox. + + :ivar metric_specifications: Metric specifications for exposing performance metrics to shoebox. + :vartype metric_specifications: list[~azure.mgmt.powerbidedicated.models.MetricSpecification] + :ivar log_specifications: Log specifications for exposing diagnostic logs to shoebox. + :vartype log_specifications: list[~azure.mgmt.powerbidedicated.models.LogSpecification] + """ + + _attribute_map = { + 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, + } + + def __init__( + self, + *, + metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["LogSpecification"]] = None, + **kwargs + ): + """ + :keyword metric_specifications: Metric specifications for exposing performance metrics to + shoebox. + :paramtype metric_specifications: list[~azure.mgmt.powerbidedicated.models.MetricSpecification] + :keyword log_specifications: Log specifications for exposing diagnostic logs to shoebox. + :paramtype log_specifications: list[~azure.mgmt.powerbidedicated.models.LogSpecification] + """ + super(ServiceSpecification, self).__init__(**kwargs) + self.metric_specifications = metric_specifications + self.log_specifications = log_specifications + + class SkuDetailsForExistingResource(msrest.serialization.Model): """An object that represents SKU details for existing resources. - :param sku: The SKU in SKU details for existing resources. - :type sku: ~azure.mgmt.powerbidedicated.models.CapacitySku + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar sku: The SKU in SKU details for existing resources. + :vartype sku: ~azure.mgmt.powerbidedicated.models.CapacitySku """ _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'CapacitySku'}, } def __init__( self, *, + resource_type: Optional[str] = None, sku: Optional["CapacitySku"] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword sku: The SKU in SKU details for existing resources. + :paramtype sku: ~azure.mgmt.powerbidedicated.models.CapacitySku + """ super(SkuDetailsForExistingResource, self).__init__(**kwargs) + self.resource_type = resource_type self.sku = sku class SkuEnumerationForExistingResourceResult(msrest.serialization.Model): """An object that represents enumerating SKUs for existing resources. - :param value: The collection of available SKUs for existing resources. - :type value: list[~azure.mgmt.powerbidedicated.models.SkuDetailsForExistingResource] + :ivar value: The collection of available SKUs for existing resources. + :vartype value: list[~azure.mgmt.powerbidedicated.models.SkuDetailsForExistingResource] """ _attribute_map = { @@ -808,6 +1256,10 @@ def __init__( value: Optional[List["SkuDetailsForExistingResource"]] = None, **kwargs ): + """ + :keyword value: The collection of available SKUs for existing resources. + :paramtype value: list[~azure.mgmt.powerbidedicated.models.SkuDetailsForExistingResource] + """ super(SkuEnumerationForExistingResourceResult, self).__init__(**kwargs) self.value = value @@ -815,8 +1267,8 @@ def __init__( class SkuEnumerationForNewResourceResult(msrest.serialization.Model): """An object that represents enumerating SKUs for new resources. - :param value: The collection of available SKUs for new resources. - :type value: list[~azure.mgmt.powerbidedicated.models.CapacitySku] + :ivar value: The collection of available SKUs for new resources. + :vartype value: list[~azure.mgmt.powerbidedicated.models.CapacitySku] """ _attribute_map = { @@ -829,6 +1281,10 @@ def __init__( value: Optional[List["CapacitySku"]] = None, **kwargs ): + """ + :keyword value: The collection of available SKUs for new resources. + :paramtype value: list[~azure.mgmt.powerbidedicated.models.CapacitySku] + """ super(SkuEnumerationForNewResourceResult, self).__init__(**kwargs) self.value = value @@ -836,20 +1292,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: An identifier for 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.powerbidedicated.models.IdentityType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: An identifier for 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: An identifier for 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.powerbidedicated.models.IdentityType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: An identifier for 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.powerbidedicated.models.IdentityType - :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.powerbidedicated.models.IdentityType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -872,6 +1328,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: An identifier for 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.powerbidedicated.models.IdentityType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: An identifier for 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.powerbidedicated.models.IdentityType + :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/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_power_bi_dedicated_enums.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_power_bi_dedicated_enums.py index 577b86f2d997f..f64dafee33990 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_power_bi_dedicated_enums.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/models/_power_bi_dedicated_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 CapacityProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CapacityProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current deployment state of PowerBI Dedicated resource. The provisioningState is to indicate states for resource provisioning. """ @@ -44,7 +29,7 @@ class CapacityProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, En PREPARING = "Preparing" SCALING = "Scaling" -class CapacitySkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CapacitySkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the Azure pricing tier to which the SKU applies. """ @@ -52,7 +37,7 @@ class CapacitySkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PREMIUM = "Premium" AUTO_PREMIUM_HOST = "AutoPremiumHost" -class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created/modified the resource. """ @@ -61,14 +46,16 @@ class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class Mode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The capacity mode. +class Mode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Specifies the generation of the Power BI Embedded capacity. If no value is specified, the + default value 'Gen2' is used. `Learn More + `_ """ GEN1 = "Gen1" GEN2 = "Gen2" -class State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current state of PowerBI Dedicated resource. The state is to indicate more states outside of resource provisioning. """ @@ -86,14 +73,14 @@ class State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PREPARING = "Preparing" SCALING = "Scaling" -class VCoreProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VCoreProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current deployment state of an auto scale v-core resource. The provisioningState is to indicate states for resource provisioning. """ SUCCEEDED = "Succeeded" -class VCoreSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VCoreSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the Azure pricing tier to which the SKU applies. """ diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_auto_scale_vcores_operations.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_auto_scale_vcores_operations.py index 38ae7039470e8..b286f783d7f19 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_auto_scale_vcores_operations.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_auto_scale_vcores_operations.py @@ -5,23 +5,248 @@ # 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') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + vcore_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "vcoreName": _SERIALIZER.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), + } + + 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_request( + subscription_id: str, + resource_group_name: str, + vcore_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "vcoreName": _SERIALIZER.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), + } + + 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_delete_request( + subscription_id: str, + resource_group_name: str, + vcore_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "vcoreName": _SERIALIZER.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), + } + + 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_update_request( + subscription_id: str, + resource_group_name: str, + vcore_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "vcoreName": _SERIALIZER.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), + } + + 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_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + 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-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/autoScaleVCores') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AutoScaleVCoresOperations(object): """AutoScaleVCoresOperations operations. @@ -45,13 +270,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - vcore_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoScaleVCore" + resource_group_name: str, + vcore_name: str, + **kwargs: Any + ) -> "_models.AutoScaleVCore": """Gets details about the specified auto scale v-core. :param resource_group_name: The name of the Azure Resource group of which a given @@ -71,33 +296,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vcoreName': self._serialize.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), - } - 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, + vcore_name=vcore_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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoScaleVCore', pipeline_response) @@ -106,16 +321,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}'} # type: ignore + + @distributed_trace def create( self, - resource_group_name, # type: str - vcore_name, # type: str - v_core_parameters, # type: "_models.AutoScaleVCore" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoScaleVCore" + resource_group_name: str, + vcore_name: str, + v_core_parameters: "_models.AutoScaleVCore", + **kwargs: Any + ) -> "_models.AutoScaleVCore": """Provisions the specified auto scale v-core based on the configuration specified in the request. :param resource_group_name: The name of the Azure Resource group of which a given @@ -137,38 +354,28 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vcoreName': self._serialize.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), - } - 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(v_core_parameters, 'AutoScaleVCore') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcore_name=vcore_name, + content_type=content_type, + json=_json, + template_url=self.create.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(v_core_parameters, 'AutoScaleVCore') - 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._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('AutoScaleVCore', pipeline_response) @@ -177,15 +384,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - vcore_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + vcore_name: str, + **kwargs: Any + ) -> None: """Deletes the specified auto scale v-core. :param resource_group_name: The name of the Azure Resource group of which a given @@ -205,33 +414,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vcoreName': self._serialize.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), - } - 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, + vcore_name=vcore_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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -239,14 +438,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - vcore_name, # type: str - v_core_update_parameters, # type: "_models.AutoScaleVCoreUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoScaleVCore" + resource_group_name: str, + vcore_name: str, + v_core_update_parameters: "_models.AutoScaleVCoreUpdateParameters", + **kwargs: Any + ) -> "_models.AutoScaleVCore": """Updates the current state of the specified auto scale v-core. :param resource_group_name: The name of the Azure Resource group of which a given @@ -258,7 +458,8 @@ def update( :type vcore_name: str :param v_core_update_parameters: Request object that contains the updated information for the auto scale v-core. - :type v_core_update_parameters: ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreUpdateParameters + :type v_core_update_parameters: + ~azure.mgmt.powerbidedicated.models.AutoScaleVCoreUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoScaleVCore, or the result of cls(response) :rtype: ~azure.mgmt.powerbidedicated.models.AutoScaleVCore @@ -269,38 +470,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vcoreName': self._serialize.url("vcore_name", vcore_name, 'str', max_length=63, min_length=3, pattern=r'^[-a-zA-Z0-9_]+$'), - } - 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(v_core_update_parameters, 'AutoScaleVCoreUpdateParameters') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcore_name=vcore_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(v_core_update_parameters, 'AutoScaleVCoreUpdateParameters') - 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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoScaleVCore', pipeline_response) @@ -309,14 +500,16 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/autoScaleVCores/{vcoreName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutoScaleVCoreListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AutoScaleVCoreListResult"]: """Gets all the auto scale v-cores for the given resource group. :param resource_group_name: The name of the Azure Resource group of which a given @@ -324,8 +517,10 @@ def list_by_resource_group( more than 90. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoScaleVCoreListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.powerbidedicated.models.AutoScaleVCoreListResult] + :return: An iterator like instance of either AutoScaleVCoreListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.powerbidedicated.models.AutoScaleVCoreListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoScaleVCoreListResult"] @@ -333,35 +528,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - '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('AutoScaleVCoreListResult', pipeline_response) + deserialized = self._deserialize("AutoScaleVCoreListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -374,27 +565,30 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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.PowerBIDedicated/autoScaleVCores'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutoScaleVCoreListResult"] + **kwargs: Any + ) -> Iterable["_models.AutoScaleVCoreListResult"]: """Lists all the auto scale v-cores for the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoScaleVCoreListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.powerbidedicated.models.AutoScaleVCoreListResult] + :return: An iterator like instance of either AutoScaleVCoreListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.powerbidedicated.models.AutoScaleVCoreListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoScaleVCoreListResult"] @@ -402,34 +596,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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'), - } - 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('AutoScaleVCoreListResult', pipeline_response) + deserialized = self._deserialize("AutoScaleVCoreListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -442,12 +631,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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 ) diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_capacities_operations.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_capacities_operations.py index f2948c55082c6..9c2e972c5f83e 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_capacities_operations.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_capacities_operations.py @@ -5,25 +5,428 @@ # 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +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_get_details_request( + resource_group_name: str, + dedicated_capacity_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "dedicatedCapacityName": _SERIALIZER.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request_initial( + resource_group_name: str, + dedicated_capacity_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "dedicatedCapacityName": _SERIALIZER.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + 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_delete_request_initial( + resource_group_name: str, + dedicated_capacity_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "dedicatedCapacityName": _SERIALIZER.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + dedicated_capacity_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "dedicatedCapacityName": _SERIALIZER.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + 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_suspend_request_initial( + resource_group_name: str, + dedicated_capacity_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/suspend') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "dedicatedCapacityName": _SERIALIZER.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_resume_request_initial( + resource_group_name: str, + dedicated_capacity_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/resume') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "dedicatedCapacityName": _SERIALIZER.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/capacities') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_skus_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/skus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_skus_for_capacity_request( + resource_group_name: str, + dedicated_capacity_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/skus') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "dedicatedCapacityName": _SERIALIZER.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + location: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/locations/{location}/checkNameAvailability') + path_format_arguments = { + "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + 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 CapacitiesOperations(object): """CapacitiesOperations operations. @@ -47,13 +450,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_details( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DedicatedCapacity" + resource_group_name: str, + dedicated_capacity_name: str, + **kwargs: Any + ) -> "_models.DedicatedCapacity": """Gets details about the specified dedicated capacity. :param resource_group_name: The name of the Azure Resource group of which a given @@ -73,33 +476,23 @@ def get_details( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_details.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_details_request( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self.get_details.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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DedicatedCapacity', pipeline_response) @@ -108,54 +501,44 @@ def get_details( return cls(pipeline_response, deserialized, {}) return deserialized + get_details.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore + def _create_initial( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - capacity_parameters, # type: "_models.DedicatedCapacity" - **kwargs # type: Any - ): - # type: (...) -> "_models.DedicatedCapacity" + resource_group_name: str, + dedicated_capacity_name: str, + capacity_parameters: "_models.DedicatedCapacity", + **kwargs: Any + ) -> "_models.DedicatedCapacity": cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacity"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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(capacity_parameters, 'DedicatedCapacity') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.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(capacity_parameters, 'DedicatedCapacity') - 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(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('DedicatedCapacity', pipeline_response) @@ -167,16 +550,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - capacity_parameters, # type: "_models.DedicatedCapacity" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DedicatedCapacity"] + resource_group_name: str, + dedicated_capacity_name: str, + capacity_parameters: "_models.DedicatedCapacity", + **kwargs: Any + ) -> LROPoller["_models.DedicatedCapacity"]: """Provisions the specified Dedicated capacity based on the configuration specified in the request. @@ -191,15 +576,19 @@ def begin_create( :type capacity_parameters: ~azure.mgmt.powerbidedicated.models.DedicatedCapacity :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DedicatedCapacity or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DedicatedCapacity or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacity"] lro_delay = kwargs.pop( 'polling_interval', @@ -211,27 +600,21 @@ def begin_create( resource_group_name=resource_group_name, dedicated_capacity_name=dedicated_capacity_name, capacity_parameters=capacity_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DedicatedCapacity', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -243,61 +626,51 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + dedicated_capacity_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + dedicated_capacity_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified Dedicated capacity. :param resource_group_name: The name of the Azure Resource group of which a given @@ -309,15 +682,17 @@ def begin_delete( :type dedicated_capacity_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -331,21 +706,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -357,54 +725,43 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - capacity_update_parameters, # type: "_models.DedicatedCapacityUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.DedicatedCapacity" + resource_group_name: str, + dedicated_capacity_name: str, + capacity_update_parameters: "_models.DedicatedCapacityUpdateParameters", + **kwargs: Any + ) -> "_models.DedicatedCapacity": cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacity"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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(capacity_update_parameters, 'DedicatedCapacityUpdateParameters') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.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(capacity_update_parameters, 'DedicatedCapacityUpdateParameters') - 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, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('DedicatedCapacity', pipeline_response) @@ -416,16 +773,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - capacity_update_parameters, # type: "_models.DedicatedCapacityUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DedicatedCapacity"] + resource_group_name: str, + dedicated_capacity_name: str, + capacity_update_parameters: "_models.DedicatedCapacityUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.DedicatedCapacity"]: """Updates the current state of the specified Dedicated capacity. :param resource_group_name: The name of the Azure Resource group of which a given @@ -437,18 +796,23 @@ def begin_update( :type dedicated_capacity_name: str :param capacity_update_parameters: Request object that contains the updated information for the capacity. - :type capacity_update_parameters: ~azure.mgmt.powerbidedicated.models.DedicatedCapacityUpdateParameters + :type capacity_update_parameters: + ~azure.mgmt.powerbidedicated.models.DedicatedCapacityUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DedicatedCapacity or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DedicatedCapacity or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.powerbidedicated.models.DedicatedCapacity] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedCapacity"] lro_delay = kwargs.pop( 'polling_interval', @@ -460,27 +824,21 @@ def begin_update( resource_group_name=resource_group_name, dedicated_capacity_name=dedicated_capacity_name, capacity_update_parameters=capacity_update_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DedicatedCapacity', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -492,61 +850,51 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'} # type: ignore def _suspend_initial( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + dedicated_capacity_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._suspend_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_suspend_request_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self._suspend_initial.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, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _suspend_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/suspend'} # type: ignore + + @distributed_trace def begin_suspend( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + dedicated_capacity_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Suspends operation of the specified dedicated capacity instance. :param resource_group_name: The name of the Azure Resource group of which a given @@ -558,15 +906,17 @@ def begin_suspend( :type dedicated_capacity_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -580,21 +930,14 @@ def begin_suspend( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -606,61 +949,51 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/suspend'} # type: ignore def _resume_initial( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + dedicated_capacity_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._resume_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_resume_request_initial( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self._resume_initial.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, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/resume'} # type: ignore + + @distributed_trace def begin_resume( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + dedicated_capacity_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Resumes operation of the specified Dedicated capacity instance. :param resource_group_name: The name of the Azure Resource group of which a given @@ -672,15 +1005,17 @@ def begin_resume( :type dedicated_capacity_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -694,21 +1029,14 @@ def begin_resume( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -720,14 +1048,15 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/resume'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DedicatedCapacities"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.DedicatedCapacities"]: """Gets all the Dedicated capacities for the given resource group. :param resource_group_name: The name of the Azure Resource group of which a given @@ -744,35 +1073,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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( + resource_group_name=resource_group_name, + 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('DedicatedCapacities', pipeline_response) + deserialized = self._deserialize("DedicatedCapacities", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -785,22 +1110,23 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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.PowerBIDedicated/capacities'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DedicatedCapacities"] + **kwargs: Any + ) -> Iterable["_models.DedicatedCapacities"]: """Lists all the Dedicated capacities for the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -813,34 +1139,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('DedicatedCapacities', pipeline_response) + deserialized = self._deserialize("DedicatedCapacities", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -853,22 +1174,23 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/capacities'} # type: ignore + @distributed_trace def list_skus( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.SkuEnumerationForNewResourceResult" + **kwargs: Any + ) -> "_models.SkuEnumerationForNewResourceResult": """Lists eligible SKUs for PowerBI Dedicated resource provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -881,31 +1203,21 @@ def list_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.list_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_skus_request( + subscription_id=self._config.subscription_id, + template_url=self.list_skus.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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SkuEnumerationForNewResourceResult', pipeline_response) @@ -914,15 +1226,17 @@ def list_skus( return cls(pipeline_response, deserialized, {}) return deserialized + list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/skus'} # type: ignore + + @distributed_trace def list_skus_for_capacity( self, - resource_group_name, # type: str - dedicated_capacity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SkuEnumerationForExistingResourceResult" + resource_group_name: str, + dedicated_capacity_name: str, + **kwargs: Any + ) -> "_models.SkuEnumerationForExistingResourceResult": """Lists eligible SKUs for a PowerBI Dedicated resource. :param resource_group_name: The name of the Azure Resource group of which a given @@ -942,33 +1256,23 @@ def list_skus_for_capacity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.list_skus_for_capacity.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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_skus_for_capacity_request( + resource_group_name=resource_group_name, + dedicated_capacity_name=dedicated_capacity_name, + subscription_id=self._config.subscription_id, + template_url=self.list_skus_for_capacity.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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SkuEnumerationForExistingResourceResult', pipeline_response) @@ -977,21 +1281,24 @@ def list_skus_for_capacity( return cls(pipeline_response, deserialized, {}) return deserialized + list_skus_for_capacity.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}/skus'} # type: ignore + + @distributed_trace def check_name_availability( self, - location, # type: str - capacity_parameters, # type: "_models.CheckCapacityNameAvailabilityParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckCapacityNameAvailabilityResult" + location: str, + capacity_parameters: "_models.CheckCapacityNameAvailabilityParameters", + **kwargs: Any + ) -> "_models.CheckCapacityNameAvailabilityResult": """Check the name availability in the target location. :param location: The region name which the operation will lookup into. :type location: str :param capacity_parameters: The name of the capacity. - :type capacity_parameters: ~azure.mgmt.powerbidedicated.models.CheckCapacityNameAvailabilityParameters + :type capacity_parameters: + ~azure.mgmt.powerbidedicated.models.CheckCapacityNameAvailabilityParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckCapacityNameAvailabilityResult, or the result of cls(response) :rtype: ~azure.mgmt.powerbidedicated.models.CheckCapacityNameAvailabilityResult @@ -1002,37 +1309,27 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'location': self._serialize.url("location", location, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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(capacity_parameters, 'CheckCapacityNameAvailabilityParameters') - # 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_check_name_availability_request( + location=location, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.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(capacity_parameters, 'CheckCapacityNameAvailabilityParameters') - 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(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckCapacityNameAvailabilityResult', pipeline_response) @@ -1041,4 +1338,6 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/locations/{location}/checkNameAvailability'} # type: ignore + diff --git a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_operations.py b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_operations.py index 71ca9b47ad833..f8ce0ad5b3847 100644 --- a/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_operations.py +++ b/sdk/powerbidedicated/azure-mgmt-powerbidedicated/azure/mgmt/powerbidedicated/operations/_operations.py @@ -5,23 +5,50 @@ # 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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.PowerBIDedicated/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available PowerBIDedicated REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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.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_request( + template_url=self.list.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_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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 )